static struct tm& as_struct_tm (const time_t& t, struct tm& res) { TTime us = UNIX_BASE + TTimeIntervalSeconds(t); TDateTime dt = us.DateTime(); res.tm_sec = dt.Second(); res.tm_min = dt.Minute(); res.tm_hour = dt.Hour(); res.tm_mday = dt.Day() + 1; res.tm_mon = dt.Month(); res.tm_year = dt.Year() - 1900; // EPOC32 counts the year day as Jan 1st == day 1 res.tm_yday = us.DayNoInYear() - 1; // EPOC32 counts the weekdays from 0==Monday to 6==Sunday res.tm_wday = us.DayNoInWeek() + 1; if (res.tm_wday==7) res.tm_wday=0; // Sunday==0 in a struct tm // newlib just sets this field to -1 // tm_isdst doesn't really make sense here since we don't // know the locale for which to interpret this time. res.tm_isdst = -1; return res; }