I'm A Celebrity star Aitch's dating history: From Chicken Shop Date's Amelia Dimoldenberg fling to explosive split from influencer Lola Thompson
Cost of living pressures to put brakes on mortgages
Scottish landlords MOST likely to raise rents - despite being subject to rent controls
A THIRD of home sellers have slashed their asking price ahead of dreaded Autumn Budget
Lawyers and Labour MPs to torpedo Mahmood's asylum plan: Home Secretary warned Left-wing opposition will scupper crackdown on illegal migration
Smiling girl, 14, who vanished without a trace is found dead in RV... as cops arrest her family member
Trump turns to Epstein's lawyer to prove he has 'nothing to hide' as he orders GOP to vote on releasing ALL documents to avert MAGA mutiny
Is Holly Ramsay taking tips from the Nicola Peltz playbook? Adam Peaty's fiancée sparks 'Beckxit' comparisons as she finds herself at the centre of ugly family fallout
Iconic O.J. Simpson witness looks VERY different 30 years after legendary murder trial... see him now
Tom Cruise, 63, chats up Sydney Sweeney, 28, at Governors Awards after Ana de Armas split
Live Dartford Tunnel updates as two lanes closed
Dolly Parton virtually accepts honorary Oscar after canceling Governors Awards appearance due to health concerns... and Tom Cruise FINALLY earns Academy Award
Buying a house? Gazumping insurance could save you thousands if your seller jumps ship
Survivor 'relieved' after rapist, 22, sent to prison for five years
Heart-stopping helicopter rescue of BASE jumper dangling from Utah canyon by their rainbow parachute is caught on camera
No jobs... and no incentive to keep one in Labour's Britain: Parents left in tears by childcare costs say they'd be better off with no job - and graduates struggle as youth unemployment spirals
Representative Line: In the Zone
Robert R picked up a bug in his company's event scheduling app. Sometimes, events were getting reported a day off from when they actually were.
It didn't take too long to find the culprit, and as is so often the case, the culprit was handling dates with strings.
const dateAsString = event.toISOString().substr(0,10); return new Date(dateAsString);toISOString returns a "simplified" ISO8601 string, which looks like this: YYYY-MM-DDTHH:mm:ss.sssZ. The substr pops off the first ten characters, giving you YYYY-MM-DD.
The goal, as you can likely gather, is to truncate to just the date part of a date-time. And given that JavaScript doesn't have a convenient method to do that, it doesn't seem like a terrible way to solve that problem, if you don't think about what date-times contain too hard.
But there's an obvious issue here. toISOString always converts the date to UTC, converting from your local timezone to UTC. Which means when you pick off just the date portion of that, you may be off by an entire day, depending on the event's scheduled time and your local timezone.
This code doesn't simply truncate- it discards timezone information. But for an event scheduler used across the world, tracking timezones is important. You can't just throw that information away.
[Advertisement] Plan Your .NET 9 Migration with ConfidenceYour journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!
Developer made one wrong click and sent his AWS bill into the stratosphere
Who, Me? Welcome to another week of work, a moment The Register celebrates with a new installment of Who, Me? It's the reader-contributed column in which you 'fess up to follies, false moves, and faux pas – and explain how you escaped.…