summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/time/_time.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/time/_time.h b/src/time/_time.h
new file mode 100644
index 00000000..e80bfdb7
--- /dev/null
+++ b/src/time/_time.h
@@ -0,0 +1,25 @@
+#ifndef ___TIME_H__
+#define ___TIME_H__
+
+#define SEC_PER_MIN (60L)
+
+#define MIN_PER_HR (60L)
+#define SEC_PER_HR ((SEC_PER_MIN) * (MIN_PER_HR))
+
+#define HR_PER_DAY (24L)
+#define SEC_PER_DAY ((SEC_PER_HR) * (HR_PER_DAY))
+
+#define DAY_PER_YEAR (365L) /* not counting leap year */
+#define SEC_PER_YEAR ((SEC_PER_DAY) * (DAY_PER_YEAR))
+#define MON_PER_YEAR (12L)
+
+#define ISLEAPYEAR(y) ((y) % 4L == 0 && ((y) % 100L != 0 || (y) % 400L == 0))
+
+/* it's really 1970, but tm_year is 0 based from 1900 */
+#define EPOCH_YEAR (70)
+
+/* months are zero based, so February is 1, etc. */
+#define DAYS_IN(y, m) (m == 1 ? (ISLEAPYEAR(y) ? 29 : 28) : \
+ ((m == 3 || m == 5 || m == 8 || m == 10) ? 30 : 31))
+
+#endif