# HG changeset patch # User Josef 'Jeff' Sipek # Date 1694615025 14400 # Wed Sep 13 10:23:45 2023 -0400 # Node ID bb22b8ea2242b31537908a36d4e519cad5bd01c5 # Parent 6075f43a5d72873d7e0cc02a631d532d7ab2460e time: add is_leap_year function Signed-off-by: Josef 'Jeff' Sipek diff --git a/include/jeffpc/time.h b/include/jeffpc/time.h --- a/include/jeffpc/time.h +++ b/include/jeffpc/time.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017 Josef 'Jeff' Sipek + * Copyright (c) 2016-2017,2023 Josef 'Jeff' Sipek * * 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 #include +#include #include 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