1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// SPDX-License-Identifier: MIT-0
//! The single place a local wall-clock becomes an instant.
//!
//! Every `(local day, seconds-since-local-midnight)` pair in this crate is
//! resolved here, so DST policy is stated once rather than at each call site.
//! The policy is asymmetric on purpose: an **open** takes the earliest valid
//! mapping and a **close** takes the latest, which keeps a session maximally
//! inclusive while its close stays end-exclusive at the true boundary. A
//! wall-clock inside a spring-forward gap does not exist, so the resolver steps
//! forward minute by minute — bounded — to the first representable instant.
//! The resolver is **total**: it never panics, for any time zone or input.
//!
//! Callers must resolve through [`mk_local_open`] / [`mk_local_close`] rather
//! than [`chrono::TimeZone::from_local_datetime`]: picking a bias ad hoc is how
//! fall-back hours produce sessions that appear to run backwards.
use ;
use Tz;
use MarketHours;
/// Holiday hook. Always `false` today: the crate ships normal-week,
/// exchange-level defaults and deliberately owns no holiday calendar.
///
/// Every query path routes its "may this session exist on this local date?"
/// question through here, so landing a real calendar is a body change, not a
/// control-flow change. The session-existence contract every caller
/// implements: a **same-day** session on local day `D` exists iff `D` is not
/// a holiday, and a **wrap** session opening on `D` and closing on `D+1`
/// exists iff neither `D` nor `D+1` is a holiday. `is_open_with`,
/// `session_bounds_with`, `next_session_after_with`, and the daily-close
/// finder all apply these gates identically — the cross-query fence in
/// `tests/contract/session_invariants.rs` is what keeps them from drifting.
pub
/// Resolve a local wall-clock (day + SSM) into a concrete `DateTime<Tz>`,
/// choosing a deterministic mapping across DST transitions.
/// - Ambiguous: pick earliest/latest according to `bias`.
/// - Skipped (spring forward): pick the earliest valid instant *after* the gap,
/// at minute granularity.
///
/// Total by construction: the gap search covers 50 hours — the largest gaps in
/// IANA history are the 24-hour date-line skips (Pacific/Apia 2011,
/// Pacific/Kiritimati 1994), and ordinary DST gaps are one hour — and if a
/// hypothetical zone exhausted even that, the wall-clock is deterministically
/// reinterpreted as UTC rather than panicking.
/// Resolves a session **open**: on an ambiguous fall-back hour the earliest of
/// the two valid instants wins, so the session starts as early as it legitimately can.
pub
/// Resolves a session **close**: on an ambiguous fall-back hour the latest of
/// the two valid instants wins, so the end-exclusive close lands on the true
/// boundary rather than an hour early.
pub