The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Wednesday, March 12, 2014

For now, until this can be automated

One of the tasks I do at work every day is to pull the latest updates of the several source repositories I have checked out and view the changes. It keeps me up to date. One particular change caught my eye:

r4245 | XXXXXXX | 2014-03-12 11:36:38 -0400 (Wed, 12 Mar 2014) | 1 line

update for Daylight Savings Time

Really?

We have networked computers, running the latest operating systems, and we're still manually updating the time zone? (Okay, to be fair, this is code to test code, but still …)

Now granted, getting the time zone information in a portable manner is not always that easy. In C, there is no direct way to obtain the timezone, and thus, you need to do something like:

time_t    now;
struct tm slocal;
struct tm sgmt;
time_t    local;
time_t    gmt;
double    zone;

now    = time(NULL);
slocal = *localtime(&now);
sgmt   = *gmtime(&now);
local  = mktime(&slocal);
gmt    = mktime(&sgmt);
zone   = difftime(local,gmt);

zone is the number of seconds from UT; divide by 3,600 to get the time zone (well, the quotient is the timezone, the remainder needs to be multiplied by 3,600 then divided by 60 to get the minutes).

And that's just to be “portable”—POSIX (read: most modern Unix systems these days) include a way to obtain the timezone more directly, just call tzset() and the global variables extern char *tzname[2] and extern long timezone are initialized.

You don't need to hardcode a timezone.

But I was curious, and I checked the log for the file in question:

r4245 | XXXXXXX | 2014-03-12 11:36:38 -0400 (Wed, 12 Mar 2014) | 1 line

update for Daylight Savings Time
------------------------------------------------------------------------
r3889 | XXXXXXX | 2013-11-04 13:21:02 -0500 (Mon, 04 Nov 2013) | 1 line

Support for XXXXXXXX. Changed the Manual UTC offset constant to reflect DST
change. Ran a couple tests and they were all passing after making the
change.
------------------------------------------------------------------------
r3245 | XXXXXXX | 2013-03-07 15:20:00 -0500 (Thu, 07 Mar 2013) | 1 line

Fixing utc offset for day-light savings shift.
------------------------------------------------------------------------
r2923 | XXXXXXX | 2012-11-05 11:30:04 -0500 (Mon, 05 Nov 2012) | 1 line

Adjust time offset value for daylight savings.
------------------------------------------------------------------------
r1827 | XXXXXXX | 2012-03-12 12:08:41 -0400 (Mon, 12 Mar 2012) | 1 line

Update for daylight savings time.
------------------------------------------------------------------------
r1154 | XXXXXXX | 2011-11-14 19:28:32 -0500 (Mon, 14 Nov 2011) | 1 line

Remove unneeded constants.
------------------------------------------------------------------------
r1091 | XXXXXXX | 2011-11-04 19:32:51 -0400 (Fri, 04 Nov 2011) | 1 line

Adjusting UTC_OFFSET for day light savings.

And the punchline? The comment above the timezone constant:

// UTC Offset (for now until this can be automated)

which was added in April of 2011.

Obligatory Picture

[The future's so bright, I gotta wear shades]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.