Hi there, On Sat, 16 Nov 2024, Jon Brase via Freedos-user wrote:
The list is full of corner cases ...
Reproduced below is an extract from a 'C' header file, which is still current here and is used to build systems under both DOS and Linux to handle a lot of money for both my business and those of my customers. Time and timezones were always a bit of an issue, but fortunately what really matters - as far as the tax authorities are concerned - is only the date on which a financial transaction toos place. In this system, that's stored as a (long) integer. The main comment was originally written in October 1984, which perhaps explains a reference at the time to only 22 leap seconds. It was last modified in September 1990 because of the Colorado-based time fiasco, which took me a little by surprise and caused some consternation in my sales office until I'd figured out what was going on in the libraries. 8<---------------------------------------------------------------------- ... #ifdef LINUX #include <termios.h> /* Needed for single char. terminal i/p */ #else #if __ZTC__ < 0x310 #error ZORTECH C++ compiler version 3.10 or greater required. #endif #endif #include <math.h> /* Needed for ecvt etc. */ /* System time and date are painful. Linux people tend to talk about the number of seconds since the instant between 1969 and 1970. Let's say for the sake of this discussion that we were on the Greenwich Meridian at the time. The DOS libraries that were supplied with the original Zorland C++ compiler unfortunately used the instant between 1979 and 1980 as a reference point, and all the SOS data assumes this same instant. When later on Symantec bought the Zorland (now Zortech) stuff they changed the libraries into line with Unix BUT they chose the instant between 1979 and 1980 if you were somewhere in Colorado, seven hours West of Greenwich. Sheesh. The value of TIMEOFFSET here is that seven hour difference so that when compiled with the new DOS libraries the existing data looks the same as it always did to the users. The data on a DOS system should be portable (as near as dammit) to a Linux/Unix system and vice-versa, although none of the DOS stuff ever took any notice of leap seconds. This might not be a big deal, but could conceivably make a difference if your business runs an all night takeaway. You're looking at approximately 22 leap seconds added since the beginning of 1970. */ #include <time.h> /* Needed for system date routines */ #ifdef LINUX #define TIMEZONEOFFSET 0L // We assume GMT under Linux #define TIMEOFFSET ((long)(315532809L+TIMEZONEOFFSET)) // 3652 days plus 9 leap seconds #else #undef TIMEOFFSET // DOS date - Unix date, but surprise! #define TIMEZONEOFFSET 25200L // Zortech got it wrong: see also JLOCALTIME #define TIMEOFFSET ((long)(315532800L+TIMEZONEOFFSET)) // 3652 days 1.1.70 - 31.12.79 inclusive. #endif #include <string.h> // 15.08.90 #include <stdlib.h> // 19.09.90 #include <ctype.h> // 18.10.90 ... 8<---------------------------------------------------------------------- -- 73, Ged. _______________________________________________ Freedos-user mailing list Freedos-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-user