Thread View: comp.std.c++
1 messages
1 total messages
Started by Bradd W. Szonye
Sun, 21 Apr 1996 15:33
Why no standard classes to cope with times?
Author: Bradd W. Szonye
Date: Sun, 21 Apr 1996 15:33
Date: Sun, 21 Apr 1996 15:33
42 lines
2690 bytes
2690 bytes
I have been perusing the DWP and have found nothing added to the Standard C Library for coping with times, in particular a method for computing a new time by adding an offset to a known time or finding the difference between two times. The standard mktime() almost does this well already. The fact that a "suitable" method already exists is probably why nothing was added to the standard. However, string<> was added to standardize the many differing implementations of strings. Lots of vendors provide a custom date/time object too; why were these classes not also standardized? The particular problem I run into has to do with daylight savings time. In places where DST is an issue, there's typically one day of the year that has two ranges of time from 1am to 2am and another day of the year where that time range doesn't exist. The standard doesn't seem to address this issue well. Suppose I use mktime() to create "The first Sunday in April at 1:30am"? Where I live, that time doesn't exist. What does mktime() create? Or "The first Sunday in November at 1:30am"? Where I live, there are two possible interpretations of that. Even worse, suppose I have a struct tm containing "The day before daylight savings time begins at 12pm." When I add 24 hours to tm_hours and set tm_isdst to -1, what does mktime() create? The next day at 12pm, 1pm, or 11am? Daylight savings time or not? Which semantics I want probably depends on whether I'm trying to calculate "1 day from now" or "24 hours from now." There has to be some reasonable answer to these questions; why doesn't the standard address it? Or am I just missing something? -- Bradd W. Szonye Doubleplus Corporation bradds@ix.netcom.com [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads