• Prime Mover (unregistered)

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.

• (nodebb)

All that said, it'd be nice to have an extra 24 minutes a day. I'd probably use it to sleep.

"probably"? You lack ambition. I would defintitely use it to sleep.

• Beowulff (unregistered)

Also "ElapsedSeconds mod 86400 mod 3660 mod 60" is the same as "ElapsedSeconds mod 60" because 3660 and 86400 are both multiples of 60.

• (nodebb)

There's another WTF, well, not so bad

Minutes := ElapsedSeconds mod 86400 mod 3660 div 60;
Seconds := ElapsedSeconds mod 86400 mod 3660 mod 60;

Notwithstanding the incorrect number of seconds in an hour screw up. The mod 86400 bit is unnecessary in both of these lines and the mod 3660 (* sic *) is unnecessary in the last line.

• Hanzito (unregistered)

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.

• PMF (unregistered) in reply to jeremypnet

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)!

• Mark J (unregistered)

If it were an extra 37 minutes instead of 24, it would be referencing a Martian day.

• WTFGuy (unregistered)

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.

• Nick (unregistered) in reply to PMF

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!

• John (unregistered) in reply to PMF

Article states dates in Delphli are a float, not an int.

• (nodebb)

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.

• ValentineMSmith (unregistered)

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.

• Richard Brantley (unregistered) in reply to Prime Mover

“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.

• Brian Boorman (unregistered) in reply to WTFGuy

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.

• Kleyguerth (github) in reply to Brian Boorman

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!

• (nodebb) in reply to ValentineMSmith

I wouldn't recommend mod 24 as a way of converting "hoursBetween" to "daysBetween". div 24 would be much better.

• (nodebb)

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.

• Quaestor (unregistered)

Delphi actually has functions to pick day (time) values apart into hours, minutes, and seconds, and to put them back in again.

• Vilx- (unregistered)

This also gets it all kinds of wrong when you throw DST into the mix. Luckily it's only wrong 2 days per year.

• Vilx- (unregistered)

• Eric TF Bat (unregistered)
Comment held for moderation.
• markm (unregistered) in reply to Nick
Comment held for moderation.
• Erin (unregistered) in reply to Prime Mover
Comment held for moderation.
• Musran (unregistered)

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.