From b10b4a79d40d04805ec40ae7944159782f764104 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Mon, 5 Feb 2024 12:15:39 -0500 Subject: [PATCH] Add DateTime struct and datetimePrecision enum --- Makefile | 3 ++- datetime.c | 0 include/epoch.h | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 datetime.c diff --git a/Makefile b/Makefile index 31333f3..89c3b19 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ CFLAGS += -fPIC hdrs += include/epoch.h +srcs += datetime.c srcs += epoch.c srcs += month.c srcs += weekday.c @@ -86,7 +87,7 @@ testclean: $(MAKE) -C test clean clean: - rm -rf *.a *.so *.o haggis + rm -rf *.a *.so *.o $(MAKE) -C test clean .PHONY: all shared static clean install install_include install_static \ diff --git a/datetime.c b/datetime.c new file mode 100644 index 0000000..e69de29 diff --git a/include/epoch.h b/include/epoch.h index d237424..ad9d7a2 100644 --- a/include/epoch.h +++ b/include/epoch.h @@ -60,9 +60,30 @@ typedef struct { typedef struct { timeZoneTag tag; - TzOffset *offset; + TzOffset *offset; } TimeZone; +typedef struct { + Year year; + Month month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + int64_t microseconds; + TimeZone zone; +} DateTime; + +typedef enum { + YearPrecision, + MonthPrecision, + DayPrecision, + HourPrecision, + MinutePrecision, + SecondPrecision, + MicrosecondPrecision, +} datetimePrecision; + void yearNew(Year *year, int32_t inner); uint16_t yearGetDays(Year *year); int64_t yearGetSeconds(Year *year);