28static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 };
29static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 };
45 return 6 - positive_mod(
j, 4) * 2;
55 c1 = century_value(positive_mod(y, 400) / 100);
56 y1 = positive_mod(y, 100);
58 dow = positive_mod((c1 + y1 + m1 + (y1 / 4) + d), 7);
69 return timelib_day_of_week_ex(y, m, d, 0);
74 return timelib_day_of_week_ex(y, m, d, 1);
78static int d_table_common[13] = { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
79static int d_table_leap[13] = { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
80static int ml_table_common[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
81static int ml_table_leap[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
85 return (
timelib_is_leap(y) ? d_table_leap[m] : d_table_common[m]) + d - 1;
95 int y_leap, prev_y_leap, doy, jan1weekday, weekday;
100 if (y_leap && m > 2) {
105 if (weekday == 0) weekday = 7;
106 if (jan1weekday == 0) jan1weekday = 7;
108 if (doy <= (8 - jan1weekday) && jan1weekday > 4) {
110 if (jan1weekday == 5 || (jan1weekday == 6 && prev_y_leap)) {
122 i = y_leap ? 366 : 365;
123 if ((i - (doy - y_leap)) < (4 - weekday)) {
133 j = doy + (7 - weekday) + (jan1weekday - 1);
135 if (jan1weekday > 4) {
144 *
id = timelib_day_of_week_ex(y, m, d, 1);
154 day = 0 - (dow > 4 ? dow - 7 : dow);
157 return day + ((iw - 1) * 7) +
id;
177 while (daynr > (is_leap_year ? 366 : 365)) {
178 daynr -= is_leap_year ? 366 : 365;
183 table = is_leap_year ? ml_table_leap : ml_table_common;
187 while (daynr > table[*m]) {
197 if (h < 0 || h > 23 || i < 0 || i > 59 ||
s < 0 || s > 59) {
printf(string $format, mixed ... $values)
void timelib_date_from_isodate(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y, timelib_sll *m, timelib_sll *d)
void timelib_isodate_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iy, timelib_sll *iw, timelib_sll *id)
timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy)
timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d)
timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d)
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m)
timelib_sll timelib_daynr_from_weeknr(timelib_sll iy, timelib_sll iw, timelib_sll id)
int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s)
signed long long timelib_sll
#define timelib_is_leap(y)