Representation of dates before the era

We have a special C ++ datetime class that represents the time in the number of seconds elapsed from the era. This is saved as int64. This class provides a number of helper functions for reading and writing various types of datetime formats.

Unfortunately, it cannot handle dates before the era, because its methods rely on gmtime () and mktime () for many operations that do not support dates before the era on our Windows system. Does anyone know about replacing gmtime and mktime that support negative values ​​in windows.

An example of this limitation is our inability to keep birthdays until 1970, because each date must use this class.

I don’t understand what I am asking, it is because of my limited knowledge about the implementation / use of date and time and my unwillingness to understand this huge class of heritage, so if you feel that this question can be framed differently or I may look for something else, do not hesitate to offer.

+4
source share
1 answer

You can use Boost.DateTime or use the Win32 API , not CRT.

You probably have a lot of tests ahead of you to ensure that the processing of the data does not change with your revision. Before you start refactoring, make sure that you have comprehensive unit tests for a library.

If you think your values ​​are valid in different places of the world, use UTC time as your canonical form and translate to / from the local time necessary for a reasonable input / display.

+3
source

All Articles