use crate::token::DateToken;
const TZ_MAX_TIMES: usize = 2000;
const TZ_MAX_TYPES: usize = 256;
#[allow(dead_code)]
const TZ_MAX_CHARS: usize = 50;
const TZ_STRLEN_MAX: usize = 255;
const TZ_MAX_LEAPS: usize = 50;
#[derive(Copy, Clone)]
#[allow(dead_code)]
struct TimeInfo {
tt_utoff: i32, tt_isdst: bool, tt_desigidx: i32, tt_ttisstd: bool, tt_ttisut: bool, }
impl TimeInfo {
#[inline]
const fn new() -> Self {
Self {
tt_utoff: 0,
tt_isdst: false,
tt_desigidx: 0,
tt_ttisstd: false,
tt_ttisut: false,
}
}
}
#[derive(Copy, Clone)]
#[allow(dead_code)]
struct LeapInfo {
ls_trans: i64, ls_corr: i64, }
impl LeapInfo {
#[inline]
const fn new() -> Self {
Self {
ls_trans: 0,
ls_corr: 0,
}
}
}
#[allow(dead_code)]
pub struct State {
leap_cnt: i32,
time_cnt: i32,
type_cnt: i32,
char_cnt: i32,
go_back: bool,
o_ahead: bool,
ats: [i64; TZ_MAX_TIMES],
types: [u8; TZ_MAX_TIMES],
ttis: [TimeInfo; TZ_MAX_TYPES],
chars: [u8; 2 * (TZ_STRLEN_MAX + 1)],
ls_info: [LeapInfo; TZ_MAX_LEAPS],
default_type: i32,
}
impl State {
#[inline]
const fn new() -> Self {
Self {
leap_cnt: 0,
time_cnt: 0,
type_cnt: 0,
char_cnt: 0,
go_back: false,
o_ahead: false,
ats: [0; TZ_MAX_TIMES],
types: [0; TZ_MAX_TIMES],
ttis: [TimeInfo::new(); TZ_MAX_TYPES],
chars: [0; 2 * (TZ_STRLEN_MAX + 1)],
ls_info: [LeapInfo::new(); TZ_MAX_LEAPS],
default_type: 0,
}
}
}
pub struct PgTimezone {
pub name: [u8; TZ_STRLEN_MAX],
pub state: State,
}
impl PgTimezone {
#[inline]
pub const fn new() -> Self {
Self {
name: [0; TZ_STRLEN_MAX],
state: State::new(),
}
}
}
#[allow(dead_code)]
pub struct TimeZoneAbbrevTable {
pub tbl_size: usize, pub num_abb_revs: i32, pub abbrevs: *mut DateToken, }
#[cfg(test)]
mod tests {
use crate::common::*;
use crate::timezone::PgTimezone;
use crate::token::*;
#[test]
fn test_date_token() {
let token = DateToken::new("Reserve".as_bytes(), TokenType::MONTH, 2);
assert_eq!(token.ty, TokenType::MONTH);
let _timezone = PgTimezone::new();
let (t, q) = time_modulo(30, 40);
assert_eq!(t, 30);
assert_eq!(q, 0);
}
}