Nicola Peltz calls her brother 'my favourite human in the entire world' in gushing post as she ignores Brooklyn Beckham furore amid claims SHE is behind trolling advert that's left him 'even more cut off' from his family
Starmer condemns 'reckless' Russian warship for firing warning shots at pensioners on yacht in the Channel
Jesy Nelson dances in a yellow crop top and celebrates her 'best birthday ever' with gal pals as she shrugs off Perrie Edwards drama after being branded 'difficult'
Harry Potter star Rupert Grint's plans to convert £5.4m mansion into 15 homes are finally given green light - but he'll have to pay up to £200K towards local schools and the council
Plans to transform garages into 'distinctive' new homes in Dagenham
Queen Camilla's surprising new friend: Why she's struck up a close bond with Spice Girl Geri Halliwell: RICHARD EDEN
Jeremy Clarkson reveals he has cancer: Tearful presenter shares devastating diagnosis while filming for Clarkson's Farm
Tesco is sprinting to quit VMware and Broadcom despite rapid migration risks
Katie Price's husband Lee Andrews claims he was 'captured at gunpoint, slapped around and suspected of spying' as he slams ex fiancée Alana Percival for spreading 'false' stories
Toy Story 5 is branded 'a welcome return to form' by critics as the 'sublime' sequel is lauded for its 'digital age backdrop', Joan Cusack's leading turn and Taylor Swift's 'insanely catchy' song
Interiors expert reveals how the wrong paint shade can make your home look like a 'fast food restaurant' with 'gravy walls' - as the UK's favourite regional decor colours are revealed
Uma Thurman's father Robert dead at 84: Buddhist monk made history in encounter with Dalai Lama
Plans for 150 homes in Essex village 'will cause total destruction'
AI and Brain-Computer Interface Allow Speechless ALS Patient To Work a Full-Time Job
Read more of this story at Slashdot.
Warning over parking fine scam targeting Essex vehicle owners
Warning over parking fine scam targeting Essex vehicle owners
How to avoid Middle East mayhem to reach incredible holiday spots in Asia and Australia - with flights as low as £438
Major overhaul of murder laws could see crime split into 'first' and 'second' degree under Law Commission plans
Developers build the best tools for developers – and are now defanging the AI menace
CodeSOD: Weekly Calculated
There's a language out there called "Progress Advanced Business Language" (or "Open Edge Advanced Business Language"). Just hearing that string of words in a sequence tells you you're in for it. It's a verbose, "English-like" programming language. But we're not here to pick on the language.
A long time ago, Mirjam had the "pleasure" of working in a Progress ABL environment. At some point, one of the developers had needed to find a date six months prior to the current date. It didn't need to be accurate, and thus said developer littered the code with comments reminding everyone that it didn't need to be that accurate. They arguably spent more time defending the choice to be inaccurate than it would have taken to write code that would have been accurate.
Mirjam doesn't have the code anymore, so what we have here is a mix of her remembered pseudocode, Progress syntax, and my attempts to clarify all of it. Let's not worry too much about the language, and instead focus on the logic:
ASSIGN v-date = TODAY. /* Calculates the current week/year */ RUN week.p(INPUT v-date, OUTPUT v-weeknumber, OUTPUT v-year). IF v-weeknumber > 26 THEN ASSIGN v-weeknumber = v-weeknumber - 26. ELSE ASSIGN v-weeknumber = 52 - 26 - v-weeknumber v-year = v-year - 1. /* Turn the result of that calculation back into a date */ RUN week2.p(INPUT v-weeknumber, INPUT v-year, OUTPUT v-resultdate).This code gets the current date. It then breaks that into week number of the date (1-52), and the year of the date. Then, if the week number is greater than 26, it subtracts 26 from it, giving us a date half a year ago, ish. If the current weak number is less than or equal to 26, we do 52 - 26 - v-weeknumber, and decrement the year. Which yes, is a fairly round about way to handle the rollover- 52 - 26 happens to be… 26.
It's worth noting, that as primitive looking as this syntax is, Progress ABL does have an ADD_INTERVAL function, which lets you do date arithmetic, without all this nonsense. In fact, Mirjam went ahead and replaced all of this with a single line.
That said, as a little bonus WTF, Progress does have some weird date quirks, for example, you can construct a date from an integer. Which has a very unsurprising (but also, weirdly surprising) range of possible values:
The value of the expression cannot be a date value before 12/31/-32768 or after 12/31/32767.
At least that covers a range that includes both the discovery of agriculture and the eventual rediscovery of agriculture after the event that enters into legend as "The Fall".