Time Zones

I’ve been debugging my timezone stuff somewhat casually, but I think I have it to the point where I’m willing to admit that I wrote it. 😎

This paper also references a trivial library that I’ve mentioned before.

If anybody who cares can think of any cool features that I should add, please let me know, either in the comments or in a private e-mail message.

I can now finish my larger civil time library which contains classes that are intended to be the C++ equivalents of SQL’s datetime types, which in turn will be part of a database access library.  (I’m still having fun in my retirement.)

Some Fun Time Zone Geekiness

There were a few e-mail messages on the FtB backchannel a little while ago.  An FtB blogger who lives in Ireland was wondering when the next FtB Podish-Sortacast will happen (https://freethoughtblogs.com/pharyngula/2024/03/09/in-my-prime/, scroll down a bit), probably just under an hour from when I get this posted.

That got me to thinking about civil time in the Irish Republic.  It winds up that they observe the same time as Great Britain and Northern Ireland, except they get there with rather tortured reasoning.

In the U.K., they switch from “Greenwich Mean Time” (GMT, same as UTC+0) to “British Summer Time” (BST, UTC+1) on the last Sunday in March at 01:00:00 local wall clock time, and they switch back from BST to GMT on the last Sunday in November at 02:00:00 local wall clock time.

In Ireland, they switch from ”Irish Standard Time” (IST, UTC+1) to GMT on the last Sunday in November at 02:00, and they switch back from GMT to IST on the last Sunday in March at 01:00.

Yes, really. Go figure. 😎

The POSIX TZ environment variable for Europe/London:  GMT0BST,M3.5.0/1,M10.5.0
The POSIX TZ environment variable for Europe/Dublin:  IST-1GMT0,M10.5.0,M3.5.0/1

Why did they bother?

A Couple of C++ Quickies

I wrote two fairly trivial libraries to support my development of the timezone class that I’ve mentioned before.

1.  Reading Directories in C++ describes a class that loops through directories.  It’s portable to both POSIX and Windows so that you don’t have to do that in two very different ways.

2.  Getting Zoneinfo Data on Windows describes a simple way to do what the title says along with a couple of functions that let you create and delete symbolic links on Windows.

Both of those are really old news, and neither has any great ideas of my own, so all that code is in the public domain.

The timezone class is finished, but I still need to do some testing before I release the code to the world and, perhaps, embarrass myself. 😎  I hope to have that done later today.

Reading Directories in C++

This one is trivial.

For testing my timezone code, I often need to recurse through all the directories where the Zoneinfo binary files are.  I got tired of rewriting the programs depending on whether I was testing on Linux or Windows, so I decided to write a little framework that would be portable to both operating systems.  It doesn’t solve all the problems (the two systems provide different information about directory entries), but at least I don’t have to completely restructure the main loops. 😎

There are no new ideas here:  how to loop through directories is really old news; and since it’s not particularly original on my part, all the code is in the public domain.

Time Zones in C++

I’m back to working on a database access library in C++ and, at present, I’m developing a library of civil time classes that would mimic SQL’s datetime types.  In the next two or three days, I hope to have a timezone class ready for prime time; and I’ve decided to document it separately from the rest of the civil time library because there’s no reason why it couldn’t be a stand-alone class in its own right.

I don’t have the final code ready to share yet, but I wanted to make the design available while the class is still under development in case there’s anybody out there who would like to suggest any additional features that I haven’t thought of.

Is there anything else you think I need?

Update:  I just found out that Windows’ filesystem does indeed support symbolic links.  (I’m not sure what planet I’ve been living on.)  I’ve also figured out an easy way to create a .zip archive with the symlinks in it* and unzip that on my Windows box.  I guess I have a bit of a redesign to work on. 😎

*I can also create a .tar.gz that’s about one fifth the size of the .zip file, but I don’t see how to get the links as links (rather than copies of the file), and the .zip file is only about 2.5Mb.

The Big Picture

Robert Reich likes to draw cartoons.

I’m on one of his e-mail lists, and early this morning I got a message that contains a link to a video of him drawing a really big one (ca. 6½ minutes) explaining how the economy got into the state that it’s in.

That was cute; but there should be an image, like maybe a JPEG, of the completed drawing so that we can see the whole thing all at once.  It doesn’t matter if it’s huge:  it would be good to be able to scroll around and zoom in/out.

Travel to Wrocław in the Fall

I got an e-mail message last night giving the dates are for the C++ standards committee meeting in Wrocław, Poland, so I’ve made some preliminary guesses about what my travel itinerary might look like.  There are still some unknowns, however; although it’ll almost certainly be Amtrak between St. Louis and Boston, Icelandair between Boston and some city in Europe, and then one or more trains to/from Wrocław.

As I’ve said before, I don’t like flying very much; and so I take Icelandair to/from Boston, mostly because I like getting off the plane and stretching my legs in Keflavík.  Also, I can usually afford Saga Class on Icelandair if I don’t try to afford other stuff that I don’t really want that much anyway; but business class on other airlines is typically pricier.

We’ll see how it actually works out…

More on Big Numbers in C++

I’ve been rather lackadaisical about fixing my “big number” classes, but I’ve finally gotten up off the couch, and I have new versions available.

I’ve changed the names of the bigint and bigdec classes to integer and decimal, respectively, because I thought the “big…” names smelled of Java.  I also wrote a small Web page that ties the three classes together.

In a comment to a previous post, Andrew Dalke suggested some additional values I could test; and, sure enough, I found a bug (thanks).  (The bug was actually in what’s now called the integer class:  I hadn’t guarded against aliasing of the operands to expressions like x *= x.)

I think I remember someone suggesting that some users might prefer classes with “more features”.  What additional features did you have in mind?  Don’t suggest trig. functions and the like:  I’ve limited the <cmath>-like functions that take decimal and rational arguments to those that return exact values.  (You might be able to talk me into square root, but that would be successive approximation using Newton’s method which is what I know how to write.  I already have a version of the rational class that has quiet NaNs and infinities and a spaceship operator, but I’m not sure I like it.)

As I’ve said before, these classes are not intended for serious numerical work; and numerics experts probably already know where to find better implementations, or could write such themselves.

Update, 2024-02-05:  I woke up this morning having in my mind a way to make rational comparisons a bit quicker, so I made that change.  I also noticed that I had failed to remove an isinf() test of the accuracy argument to the conversion from floating point values.  (In the previous version, passing a NaN for the accuracy would trigger an exact conversion using std::frexp().  In the current version, any non-finite accuracy will do that.)

By the way, if anybody out there has access to a C++ implementation where FLT_RADIX != 2, I’d appreciate a test of the frexp() business.  I have access only to boxes where FLT_RADIX is 2.

U.S. Sanctions on West-Bank Israelis

16:00 UTC−6:  DW News leads with a report that Biden has signed an executive order imposing economic sanctions on four named Israelis who were involved in anti-Palestinian violence in the West Bank.  I see this as a baby step in the right direction.  We’ll see whether U.S. policy toward Israel develops any morality.  Stay tuned…

16:30−6:  BBC World News America leads with the same story.

17:10:  my local TV news has a couple of sentences about the sanctions.  They say it’s in response to the killing of a Palestinian-American teenager.

17:30:  no mention of the sanctions on NBC Nightly News.

18:00:  nothing about the sanctions during the headlines on PBS Newshour either.

Now I’m saddened again.  NBC did have a short report about a growing movement within the Arab-American community for sitting out the next election.  They won’t vote for Trump, but they don’t think they can vote for Biden either.  Let’s hope that that doesn’t give the election to Trump.  Maybe there’s some good news in John Morales’ comment below.