Question

I am working on an embedded system. Our platform is 32-bit so time_t size is 32-bit.

For now I want to send a struct to a Windows 7 computer as a char array. One of fields of my struct is time_t. I can't change struct.

So I must send time value to Windows Machine with a 32-bit variable and when char array arrived I must convert 32 bit unsigned int value to 64-bit time_t.

I think I can't convert directly 32-bit integer to 64-bit time_t because 32-bit time_t starts from year 1970 but 64-bit start from year 1600.

So is there any way to conversion?

Was it helpful?

Solution

see: time, _time32, _time64 documentation

Both start at January 1, 1970. You only have to worry about endianness when sending it as chars.

OTHER TIPS

Is the precision, i.e. the unit, the same (seconds)? If so, then you should be able to convert the larger number by subtracting the difference and truncating to 32 bits.

Computing the required number of seconds might be a bit tricky ... I tried Wolfram Alpha but I don't know how to get a more precise answer than "1.168 * 1010 seconds".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top