| 1 |
pub const EPOCH_YEAR: u32 = 1970; |
| 2 |
|
| 3 |
pub const DAYS_PER_N_YEAR: u32 = 365; |
| 4 |
pub const DAYS_PER_L_YEAR: u32 = 366; |
| 5 |
|
| 6 |
pub const SECS_PER_MIN: u32 = 60; |
| 7 |
pub const SECS_PER_HOUR: u32 = SECS_PER_MIN * 60; |
| 8 |
pub const SECS_PER_DAY: u32 = SECS_PER_HOUR * 24; |
| 9 |
|
| 10 |
// 400-year chunks always have 146097 days (20871 weeks). |
| 11 |
pub const DAYS_PER_400_YEARS: u32 = 146_097; |
| 12 |
pub const SECS_PER_400_YEARS: u64 = DAYS_PER_400_YEARS as u64 * SECS_PER_DAY as u64; |
| 13 |
|
| 14 |
// The number of seconds in an aligned 100-year chunk, for those that |
| 15 |
// do not begin with a leap year and those that do respectively. |
| 16 |
pub const SECS_PER_100_YEARS: [u64; 2] = [ |
| 17 |
(76 * DAYS_PER_N_YEAR as u64 + 24 * DAYS_PER_L_YEAR as u64) * SECS_PER_DAY as u64, |
| 18 |
(75 * DAYS_PER_N_YEAR as u64 + 25 * DAYS_PER_L_YEAR as u64) * SECS_PER_DAY as u64, |
| 19 |
]; |
| 20 |
|
| 21 |
// The number of seconds in an aligned 4-year chunk, for those that |
| 22 |
// do not begin with a leap year and those that do respectively. |
| 23 |
#[allow(clippy::erasing_op)] |
| 24 |
pub const SECS_PER_4_YEARS: [u32; 2] = [ |
| 25 |
(4 * DAYS_PER_N_YEAR + 0 * DAYS_PER_L_YEAR) * SECS_PER_DAY, |
| 26 |
(3 * DAYS_PER_N_YEAR + DAYS_PER_L_YEAR) * SECS_PER_DAY, |
| 27 |
]; |
| 28 |
|
| 29 |
// The number of seconds in non-leap and leap years respectively. |
| 30 |
pub const SECS_PER_YEAR: [u32; 2] = [ |
| 31 |
DAYS_PER_N_YEAR * SECS_PER_DAY, |
| 32 |
DAYS_PER_L_YEAR * SECS_PER_DAY, |
| 33 |
]; |
| 34 |
|
| 35 |
// The month lengths in non-leap and leap years respectively. |
| 36 |
pub const DAYS_PER_MONTHS: [[i32; 13]; 2] = [ |
| 37 |
[-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], |
| 38 |
[-1, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], |
| 39 |
]; |
| 40 |
|
| 41 |
// The day offsets of the beginning of each (1-based) month in non-leap |
| 42 |
// and leap years respectively. |
| 43 |
// For example, in a leap year there are 335 days before December. |
| 44 |
pub const MONTHS_OFFSETS: [[i32; 14]; 2] = [ |
| 45 |
[ |
| 46 |
-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, |
| 47 |
], |
| 48 |
[ |
| 49 |
-1, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, |
| 50 |
], |
| 51 |
]; |
| 52 |
|
| 53 |
pub const DAY_OF_WEEK_TABLE: [u32; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]; |
| 54 |
|
| 55 |
pub const TM_JANUARY: usize = 0; |
| 56 |
pub const TM_DECEMBER: usize = 11; |