changeset 863:bb22b8ea2242

time: add is_leap_year function Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Wed, 13 Sep 2023 10:23:45 -0400
parents 6075f43a5d72
children 241c40daa948
files include/jeffpc/time.h
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/include/jeffpc/time.h	Tue Apr 04 20:29:03 2023 -0400
+++ b/include/jeffpc/time.h	Wed Sep 13 10:23:45 2023 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2016-2017,2023 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -26,6 +26,7 @@
 #include <jeffpc/error.h>
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include <time.h>
 
 static inline uint64_t __gettime(int clock)
@@ -57,4 +58,14 @@
 	return __gettime(CLOCK_REALTIME);
 }
 
+/*
+ * Various functions to deal with gregorian dates.
+ */
+
+/* Is the year leap? */
+static inline bool is_leap_year(int y)
+{
+	return ((y % 4) == 0) && (((y % 400) == 0) || ((y % 100) != 0));
+}
+
 #endif