libepoch/zone.c

34 lines
790 B
C
Raw Normal View History

2024-02-05 11:23:45 -05:00
#include "epoch.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
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);
}
}