cwindowstype-conversion32bit-64bittime-t

How to convert 32 bit time_t value to 64 bit time_t


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?


Solution

  • see: time, _time32, _time64 documentation

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