/* _,.---._ .-._ .--.-. ,--.--------. * _,..---._ ,-.' , - `. /==/ \ .-._/==/ //==/, - , -\ * /==/, - \ /==/_, , - \|==|, \/ /, |==\ -\\==\.-. - ,-./ * |==| _ _\==| .=. |==|- \| | \==\- \`--`\==\- \ * |==| .=. |==|_ : ;=: - |==| , | -| `--`-' \==\_ \ * |==|,| | -|==| , '=' |==| - _ | |==|- | * |==| '=' /\==\ - ,_ /|==| /\ , | |==|, | * |==|-, _`/ '.='. - .' /==/, | |- | /==/ -/ * `-.`.____.' `--`--'' `--`./ `--` `--`--` * _ __ ,---. .-._ .=-.-. _,.----. * .-`.' ,`..--.' \ /==/ \ .-._ /==/_ /.' .' - \ * /==/, - \==\-/\ \ |==|, \/ /, /==|, |/==/ , ,-' * |==| _ .=. /==/-|_\ | |==|- \| ||==| ||==|- | . * |==| , '=',\==\, - \ |==| , | -||==|- ||==|_ `-' \ * |==|- '..'/==/ - ,| |==| - _ ||==| ,||==| _ , | * |==|, | /==/- /\ - \|==| /\ , ||==|- |\==\. / * /==/ - | \==\ _.\=\.-'/==/, | |- |/==/. / `-.`.___.-' * `--`---' `--` `--`./ `--``--`-` * * @(#)Copyright (c) 2024, Nathan D. Fisher. * * This is free software. It comes with NO WARRANTY. * Permission to use, modify and distribute this source code * is granted subject to the following conditions. * 1/ that the above copyright notice and this notice * are preserved in all copies and that due credit be given * to the author. * 2/ that any changes to this code are clearly commented * as such so that the author does not get blamed for bugs * other than his own. */ #include #include "epoch.h" void yearNew(Year *year, int32_t inner) { year->year = inner; if (inner % 4 == 0 && (inner % 100 != 0 || inner % 400 == 0)) year->tag = leapYear; else year->tag = normalYear; } uint16_t yearGetDays(Year *year) { switch (year->tag) { case normalYear: return 365; case leapYear: return 366; default: return 365; } } int64_t yearGetSeconds(Year *year) { return (int64_t)yearGetDays(year) * SECONDS_PER_DAY; } int32_t yearGetInner(Year *year) { return year->year; } void yearIncrement(Year *year) { year->year += 1; if (year->year % 4 == 0 && (year->year % 100 != 0 || year->year % 400 == 0)) year->tag = leapYear; else year->tag = normalYear; } void yearDecrement(Year *year) { year->year -= 1; if (year->year % 4 == 0 && (year->year % 100 != 0 || year->year % 400 == 0)) year->tag = leapYear; else year->tag = normalYear; }