- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Office Politics
- Secret Horror
- Not Impossible
- Monkeys
- Killing Time
- Hypersensitive
- Infallabella
- Doubled Daniel
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If this is like one of the hilariously dysfunctional places I had the great good fortune to have worked at some years ago, it is quite possible there has been some push towards correcting the 3660 to 3600.
But then the users have to relearn what they are doing to accommodate the fact that their reporting software that they are running every day has changed in how it works. That means relearning their procedures so as not to put that fiddle in. (Or even to put in a different fiddle.)
And so the fix has to be reversed out again because Julie from accounts burst into tears when she was told she needed to adopt a different procedure when running the report.
BTDTBTT.
Admin
"probably"? You lack ambition. I would defintitely use it to sleep.
Admin
Also "ElapsedSeconds mod 86400 mod 3660 mod 60" is the same as "ElapsedSeconds mod 60" because 3660 and 86400 are both multiples of 60.
Admin
There's another WTF, well, not so bad
Notwithstanding the incorrect number of seconds in an hour screw up. The
mod 86400
bit is unnecessary in both of these lines and themod 3660 (* sic *)
is unnecessary in the last line.Admin
Let's be nitpicky: there are still 86400 seconds in a day, according to the first line (let's not fret about DST or similar shenanigans). They just get displayed wrong. E.g. 01:00:01, which 3601s, will be displayed as 0:60:01.
Admin
Not to mention that we know that hours, minutes and seconds will all be 0 in this case. The input value was multiplied with 86400 (seconds per day)!
Admin
If it were an extra 37 minutes instead of 24, it would be referencing a Martian day.
Admin
As much as we might wish to use the extra 24 minutes for sleep, I have no doubt our Corporate Overlords have other designs on that newly available time. By and large as between we and they, they tend to win.
Admin
Just because the input value was multiplied by 86400, doesn’t mean the seconds and minutes must be zero… the input value is not known to be an integer!
Admin
Article states dates in Delphli are a float, not an int.
Admin
Delphi has lots of date handling functions these days. Code should be maintained and updated to make good use of the current version of the compiler.
Admin
Actually, Delphi has a pretty danged robust set of date/time libraries and utilities (back in Elder Days, they were defined in DateUtils.pas. Now they're in the System.DateUtils namespace, which conveniently lives in System.DateUtils.pas).
uses System.DateUtils;
var Days, Hours, Minutes, Seconds: Integer; CurrentDT: TDateTime;
... Days := DaysBetween(CurrentDT, StartTime); Hours := HoursBetween(CurrentDT, StartTime) mod 24; // Hours per day ...
The rest is left as an exercise for the reader.
Admin
“And so the fix has to be reversed out again because Julie from accounts burst into tears when she was told she needed to adopt a different procedure when running the report.”
In my consulting days I was on a team doing a re-implementation of an old classic ASP app to MVC, and this is exactly what happened to us. The client threw a fit if we fixed a bug from the old system, so we had to re-implement the bugs too, because apparently their user base was so traumatized by change we were prohibited from making life easier for them.
I won’t say it’s why I left consulting, but it is part of why.
Admin
Assuming the extra 24 minutes are evenly distributed over the entire day, then your corporate overloads can only tell you how to use 8 of them. The other 16 are yours.
Admin
You know that's not true. The corporate overlords will shame anyone not giving the full 24 extra minutes to them as someone who is not a team player, after all you never needed those 24 extra minutes, why don't you think about your colleagues and how your selfishness will impact morale? Oh, and remember that by company policy we only track paid time in 20 minute increments so make sure to only clock out 16 minutes later so that your last 4 minutes are counted!
Admin
I wouldn't recommend
mod 24
as a way of converting "hoursBetween" to "daysBetween".div 24
would be much better.Admin
And why the stacked mod operators? Back in the stone age I've written stuff like this--but each line only needs a mod and a div.
Admin
Delphi actually has functions to pick day (time) values apart into hours, minutes, and seconds, and to put them back in again.
Admin
This also gets it all kinds of wrong when you throw DST into the mix. Luckily it's only wrong 2 days per year.
Admin
P.S. Your Google Login link is broken. :P
Admin
I thought I'd fire up Delphi to see if it was indeed true that it lacks functions to do all that date/time stuff. Halfway through the long wait to load it, I remembered that Borland/Inprise/Codegear/Embarcadero/Bouvier/Kennedy/Onassis is absolutely hopeless when it comes to help files, and I always used to just google that stuff (or more likely altavista or yahoo or anzwers it, back in those days). Then it popped up a message to say the license server didn't recognise my copy and did I want to go through the registration wizard again, and I realised how long it's been since I used Delphi, and how little I care, so I uninstalled it. So thanks, Daily WTF, for saving me several gigabytes of disk space!
Oh, and it always had date/time functions ample to this job, but if the original developers had tried to search the help files for details, it's no surprise they resorted to rolling their own. No one is to blame but the slack-jawed yokels in charge of documentation for Delphi.
Admin
'Now' (a function?) and 'StartTime' (a variable that was previously set to Now?) must be floats, where 1 = one day, and the fractional part is fractions of a day. Odd, but that's Oracle.
If I had to work with in this with a version of Oracle that lacked time and date functions other than 'Now', I'd convert hours, minutes, and seconds directly from days. This makes me wonder if the programmer copied code from a language where date and time was in seconds, adapting by first converting days to seconds.
Admin
Worse than just retraining, it's very likely that these values are stored in a database somewhere, with no way to know which ones had been manually fudged (or how accurately) making automated correction error-prone at best and likely requiring at least a manual review after doing a batch update, or possibly even just having to manually review everything.
And if that data was used to generate a report 6 months ago you can be guaranteed that some middle manager either in the company in question or worse at a customer will run the comparison and make a big snit if something is different, even if the new version is technically more correct.
Admin
Starting with (decimal) days. Developing all the way to seconds. Then working your way back up to days. All the while piling and repeating mods, divs and magic numbers.
Genius.