@@ -191,6 +191,50 @@ pub const Seconds = struct {
191
191
}
192
192
};
193
193
194
+ /// Deprecated: use `YearAndDays`.
195
+ pub const YearAndDay = struct {
196
+ year : Year ,
197
+ day : u9 ,
198
+ pub fn calculateMonthDay (self : YearAndDay ) MonthAndDay {
199
+ var month : Month = .jan ;
200
+ var days_left = self .day ;
201
+ while (true ) {
202
+ const days_in_month = getDaysInMonth (self .year , month );
203
+ if (days_left < days_in_month )
204
+ break ;
205
+ days_left -= days_in_month ;
206
+ month = @as (Month , @enumFromInt (@intFromEnum (month ) + 1 ));
207
+ }
208
+ return .{ .month = month , .day_index = @as (u5 , @intCast (days_left )) };
209
+ }
210
+ };
211
+ /// Deprecated: use `Days`.
212
+ pub const EpochDay = struct {
213
+ day : u47 ,
214
+ pub fn calculateYearDay (self : EpochDay ) YearAndDay {
215
+ var year_day = self .day ;
216
+ var year : Year = epoch_year ;
217
+ while (true ) {
218
+ const year_size = getDaysInYear (year );
219
+ if (year_day < year_size )
220
+ break ;
221
+ year_day -= year_size ;
222
+ year += 1 ;
223
+ }
224
+ return .{ .year = year , .day = @as (u9 , @intCast (year_day )) };
225
+ }
226
+ };
227
+ /// Deprecated: use `Seconds`.
228
+ pub const EpochSeconds = struct {
229
+ secs : u64 ,
230
+ pub fn getEpochDay (self : EpochSeconds ) EpochDay {
231
+ return EpochDay { .day = @as (u47 , @intCast (@divTrunc (self .secs , secs_per_day ))) };
232
+ }
233
+ pub fn getDaySeconds (self : EpochSeconds ) DaySeconds {
234
+ return DaySeconds { .secs = math .comptimeMod (self .secs , secs_per_day ) };
235
+ }
236
+ };
237
+
194
238
fn testDecode (secs : u64 , expected_year_day : YearAndDays , expected_month_day : MonthAndDay , expected_day_seconds : struct {
195
239
/// 0 to 23.
196
240
hours_into_day : u5 ,
0 commit comments