I am trying to make an easily accessible TimeDate variable, but am having problems with conversion. In time.h, how would I convert time_t (seconds since 1/1/1970), into the current local timezone (compensating for daylight savings time if applicable), so that:
time_t Seconds;
Becomes:
struct TimeDate
{
short YYYY;
unsigned char MM;
unsigned char DD;
unsigned char HH; //Non-DST, non-timezone, IE UTC (user has to add DST and TZO to get what they need)
unsigned char MM;
unsigned char S;
char TZ[4]; //This can be optionally a larger array, null terminated preferably
char TZO; //Timezone Offset from UTC
char DST; //Positive is DST (and amount of DST to apply), 0 is none, negative is unknown/error
};
Without using any string literals (bar for the timezone name) in the process (to keep it efficient)? This is also taking into account leap years. Bonus if TimeDate can be converted back into time_t.