use chrono_tz::America;
use super::super::StaticHoursProfile;
use crate::calendar::SessionRule;
use crate::calendar::rule::MON_FRI;
static B3_REGULAR_SHORT: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 10 * 3600,
close_ssm: 16 * 3600 + 55 * 60,
}];
static B3_REGULAR_INTERIM: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 10 * 3600,
close_ssm: 17 * 3600 + 25 * 60,
}];
static B3_REGULAR_OLD_SHORT: &[SessionRule] = B3_REGULAR_SHORT;
static B3_REGULAR_OLD_LONG: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 11 * 3600,
close_ssm: 17 * 3600 + 55 * 60,
}];
static B3_REGULAR_LONG: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 10 * 3600,
close_ssm: 17 * 3600 + 55 * 60,
}];
static B3_ORDER_ENTRY_0945: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 9 * 3600 + 45 * 60,
close_ssm: 10 * 3600,
}];
static B3_EXTENDED_SHORT: &[SessionRule] = &[
SessionRule {
days: MON_FRI,
open_ssm: 16 * 3600 + 55 * 60,
close_ssm: 17 * 3600,
},
SessionRule {
days: MON_FRI,
open_ssm: 17 * 3600 + 30 * 60,
close_ssm: 18 * 3600,
},
];
static B3_EXTENDED_LONG: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 17 * 3600 + 55 * 60,
close_ssm: 18 * 3600,
}];
static B3_EXTENDED_INTERIM: &[SessionRule] = &[
SessionRule {
days: MON_FRI,
open_ssm: 17 * 3600 + 25 * 60,
close_ssm: 17 * 3600 + 30 * 60,
},
SessionRule {
days: MON_FRI,
open_ssm: 18 * 3600,
close_ssm: 19 * 3600 + 30 * 60,
},
];
static B3_EXTENDED_OLD_SHORT: &[SessionRule] = &[
B3_EXTENDED_SHORT[0],
SessionRule {
days: MON_FRI,
open_ssm: 17 * 3600 + 30 * 60,
close_ssm: 19 * 3600,
},
];
static B3_EXTENDED_OLD_LONG: &[SessionRule] = &[
SessionRule {
days: MON_FRI,
open_ssm: 17 * 3600 + 55 * 60,
close_ssm: 18 * 3600,
},
SessionRule {
days: MON_FRI,
open_ssm: 18 * 3600 + 30 * 60,
close_ssm: 19 * 3600 + 30 * 60,
},
];
pub(crate) static B3_PROFILE_OLD_SHORT: StaticHoursProfile = StaticHoursProfile {
tz: America::Sao_Paulo,
regular: B3_REGULAR_OLD_SHORT,
extended: B3_EXTENDED_OLD_SHORT,
order_entry: B3_ORDER_ENTRY_0945,
has_daily_close: true,
has_weekend_close: true,
};
pub(crate) static B3_PROFILE_OLD_LONG: StaticHoursProfile = StaticHoursProfile {
tz: America::Sao_Paulo,
regular: B3_REGULAR_OLD_LONG,
extended: B3_EXTENDED_OLD_LONG,
order_entry: &[],
has_daily_close: true,
has_weekend_close: true,
};
pub(crate) static B3_PROFILE_INTERIM: StaticHoursProfile = StaticHoursProfile {
tz: America::Sao_Paulo,
regular: B3_REGULAR_INTERIM,
extended: B3_EXTENDED_INTERIM,
order_entry: B3_ORDER_ENTRY_0945,
has_daily_close: true,
has_weekend_close: true,
};
pub(crate) static B3_PROFILE_SHORT: StaticHoursProfile = StaticHoursProfile {
tz: America::Sao_Paulo,
regular: B3_REGULAR_SHORT,
extended: B3_EXTENDED_SHORT,
order_entry: B3_ORDER_ENTRY_0945,
has_daily_close: true,
has_weekend_close: true,
};
pub(crate) static B3_PROFILE_LONG: StaticHoursProfile = StaticHoursProfile {
tz: America::Sao_Paulo,
regular: B3_REGULAR_LONG,
extended: B3_EXTENDED_LONG,
order_entry: B3_ORDER_ENTRY_0945,
has_daily_close: true,
has_weekend_close: true,
};
use crate::calendar::schedules::timeline::{
Revision, effective_date, local_date, reference_delta_seconds, revisions, select_revision,
};
static EXPLICIT_REVISIONS: &[Revision] = revisions![
(2010, 3, 15, &B3_PROFILE_OLD_SHORT, "B3 OC 009/2010-DP"),
(2010, 10, 18, &B3_PROFILE_OLD_LONG, "B3 OC 002/2010-DO"),
(2011, 3, 14, &B3_PROFILE_OLD_SHORT, "B3 OC 001/2011-DO"),
(2011, 10, 17, &B3_PROFILE_OLD_LONG, "B3 OC 009/2011-DO"),
(2012, 3, 12, &B3_PROFILE_OLD_SHORT, "B3 OC 009/2012-DP"),
(2012, 12, 3, &B3_PROFILE_INTERIM, "B3 OC 066/2012-DP"),
(2013, 7, 8, &B3_PROFILE_SHORT, "B3 OC 042/2013-DP"),
];
const REFERENCE_GRID: chrono::NaiveDate = effective_date(2015, 12, 21);
pub(crate) fn profile_at(as_of: chrono::DateTime<chrono::Utc>) -> &'static StaticHoursProfile {
let day = local_date(as_of, America::Sao_Paulo);
if day < REFERENCE_GRID {
return select_revision(day, &B3_PROFILE_OLD_LONG, EXPLICIT_REVISIONS);
}
if reference_delta_seconds(as_of, America::Sao_Paulo, America::New_York) == -3600 {
&B3_PROFILE_SHORT
} else {
&B3_PROFILE_LONG
}
}