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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*!
Building blocks for supporting time zones.
*/
use crate::;
pub use ;
/// A limit on how much stack space we're willing to use for time zone
/// abbreviations.
///
/// POSIX says this:
///
/// > Indicate no less than three, nor more than {TZNAME_MAX}, bytes that are
/// > the designation for the standard (std) or the alternative (dst -such as
/// > Daylight Savings Time) timezone.
///
/// But it doesn't seem worth the trouble to query `TZNAME_MAX`. Interestingly,
/// IANA says:
///
/// > are 3 or more characters specifying the standard and daylight saving time
/// > (DST) zone abbreviations
///
/// Which implies that IANA thinks there is no limit. But that seems unwise.
/// Moreover, in practice, it seems like the `date` utility supports fairly
/// long abbreviations. On my mac (so, BSD `date` as I understand it):
///
/// ```text
/// $ TZ=ZZZ5YYYYYYYYYYYYYYYYYYYYY date
/// Sun Mar 17 20:05:58 YYYYYYYYYYYYYYYYYYYYY 2024
/// ```
///
/// And on my Linux machine (so, GNU `date`):
///
/// ```text
/// $ TZ=ZZZ5YYYYYYYYYYYYYYYYYYYYY date
/// Sun Mar 17 08:05:36 PM YYYYYYYYYYYYYYYYYYYYY 2024
/// ```
///
/// I don't know exactly what limit these programs use, but 30 seems good
/// enough?
///
/// Previously, I had been using 255 and stuffing the string in a `Box<str>`.
/// But as part of work on [#168], I was looking to remove allocation from as
/// many places as possible. And this was one candidate. But making room on the
/// stack for 255 byte abbreviations seemed gratuitous. So I picked something
/// smaller. If we come across an abbreviation bigger than this max, then we'll
/// error.
///
/// In environments with dynamic memory allocation, this maximum is just the
/// maximum number of bytes we're willing to spend on array-backed storage of
/// a time zone abbreviation. If we hit anything bigger, we'll use the heap.
///
/// In core-only environments, we use a bigger limit as mentioned above.
/// Anything bigger than this will result in a parse error.
///
/// [#168]: https://github.com/BurntSushi/jiff/issues/168
const TIME_ZONE_ABBREVIATION_MAX: usize = ;
/// When a time zone abbreviation is bigger than this, we give up and error.
const REASONABLE_ABBREVIATION_MAX: usize = ;
/// A limit on how much stack space we're willing to use for time zone
/// identifiers.
///
/// As of 2026-07-03, 32 is the length of the longest IANA time zone
/// identifier. Specifically, `America/Argentina/ComodRivadavia`. Anything
/// bigger than this will error in core-only environments and spill
/// over to the heap in all other environments. For environments with
/// a heap, we set a slightly smaller array to make the total size a
/// bit smaller (4 words on x86-64 instead of 5). This just means that
/// `America/Argentina/ComodRivadavia` will spill to the heap, but nothing else
/// should.
const TIME_ZONE_ID_MAX: usize = ;
/// A type that defines the storage for an IANA time zone identifier.
pub type TimeZoneId = ;
/// A type that defines the storage for a time zone abbreviation.
///
/// For an abbreviation whose length is less than or equal to a certain
/// implementation defined number, it will be stored inline inside an array.
/// All other cases spill out into the heap. (Unless callers do not have
/// dynamic memory allocation, in which case, whatever tried to store the
/// time zone abbreviation will return an error. For example, parsing a POSIX
/// time zone transition rule will fail in that case.)
pub type Abbreviation = ;
/// A representation a single time zone transition.
/// Information associated with an offset when doing a time zone transition
/// lookup.
///
/// Callers should generally only need the offset. This exposes additional
/// information such as the time zone abbreviation or whether a timestamp is in
/// daylight saving time or not.
/// An enum indicating whether a particular datetime is in daylight saving time
/// (DST) or not.
/// Creates a new time zone offset in a `const` context from a given number
/// of hours.
///
/// Negative offsets correspond to time zones west of the prime meridian,
/// while positive offsets correspond to time zones east of the prime
/// meridian. Equivalently, in all cases, `civil-time - offset = UTC`.
///
/// The fallible non-const version of this constructor is
/// [`Offset::from_hours`].
///
/// This is a convenience free function for [`Offset::constant`]. It is
/// intended to provide a terse syntax for constructing `Offset` values from
/// a value that is known to be valid.
///
/// # Panics
///
/// This routine panics when the given number of hours is out of range.
/// Namely, `hours` must be in the range `-25..=25`.
///
/// Similarly, when used in a const context, an out of bounds hour will prevent
/// your Rust program from compiling.
///
/// # Example
///
/// ```
/// use jiff_core::tz::offset;
///
/// let o = offset(-5);
/// assert_eq!(o.seconds(), -18_000);
/// let o = offset(5);
/// assert_eq!(o.seconds(), 18_000);
/// ```
pub const