#include "epoch.h" #include #include #include int offsetNew(TzOffset *offs, offsetSign sign, uint8_t hours, uint8_t minutes) { if (offs == NULL) return 1; if (hours > 12) return 2; if (hours > 11 && minutes > 0) return 3; if (minutes > 59) return 4; offs->sign = sign; offs->hours = hours; offs->minutes = minutes; return 0; } void printTz(TimeZone *zone) { switch (zone->tag) { case UTC: printf("UTC"); case Offset: switch (zone->offset->sign) { case Positive: puts("+"); break; case Negative: puts("-"); break; } default: break; printf("%.2u:%.2u", zone->offset->hours, zone->offset->minutes); } } int64_t timezoneAsSeconds(TimeZone *tz) { int64_t base; switch (tz->tag) { case Offset: base = (int64_t)tz->offset->hours * SECONDS_PER_HOUR + (int64_t)tz->offset->minutes * 60; switch (tz->offset->sign) { case Negative: return -base; default: return base; } default: return 0; } }