- Feature Articles
- CodeSOD
- Error'd
- 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
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.