If you call them with negative values you may get an access violation. That's because time_t has to be non negative for the Windows implementation of most of the time routines. Some programs with 30 day trial periods can behave crankily if you change the system time - may tell you that the trial period is over even after you adjust the time back again - so make sure you have no such programs running when you do it. It may sometimes cause a few problems if you vary the calendar on your computer. Test that to see how it works - but first a few warnings are in order. The zip for download includes an MSVC project to make a tiny app, that just displays the current time. Particularly, UINT could be used for file input and output. However, if you need to use them in other routines, you can convert them to UINT, which will still be valid until the end of this century and beyond. All your time_t variables will now be _int64. Place the header time64.h at the head of every file that uses the time routines. Include the source code time64.c or time64.cpp for C++ programs as part of your program. Anyone interested in converting this library to C++? Using the Code I am a pure C programmer and haven't used CTime, but maybe if you include this library, then CTime will also behave as desired - or maybe more work needs to be done. If your compiler has a native 64 bit integer type, but it has some other name, then you need to edit the source code accordingly. It is suitable for use with MSVC or any compiler that supports the _int64 data type. So, it is just a matter of interfacing with those properly, to make a 64 bit version of the C routines for Windows. The Windows operating system uses 64 bit times internally (in a rather eccentric format of 100 nanosecond intervals from 1 st January 1601). Maybe also, you want your program to work fine beyond 2038 without a new build, in case anyone uses it still in those days as a legacy app. However, maybe you want to do a 32 bit build for 32 bit operating systems. You just need to do a 64 bit build to solve it. This is the C language equivalent of the Y2K bug - but is far more easily solved. This means that if you use them in a 32-bit build, then normally, the maximum time that can be represented is Tue Jan 19 03:14:07 2038. The variable type time_t is defined as a 32 bit signed integer - to permit negative times for the seconds difference between two times. represent time as seconds from 1 st January 1970. The C time routines such as time(), localtime(), etc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |