1
1
const std = @import ("std" );
2
2
const Allocator = mem .Allocator ;
3
3
const assert = std .debug .assert ;
4
- const EpochSeconds = std .time .epoch .EpochSeconds ;
5
4
const mem = std .mem ;
6
5
const Interner = @import ("../backend.zig" ).Interner ;
7
6
const Builtins = @import ("Builtins.zig" );
@@ -200,20 +199,20 @@ fn getTimestamp(comp: *Compilation) !u47 {
200
199
}
201
200
202
201
fn generateDateAndTime (w : anytype , timestamp : u47 ) ! void {
203
- const epoch_seconds = EpochSeconds { .secs = timestamp };
204
- const epoch_day = epoch_seconds . getEpochDay ();
205
- const day_seconds = epoch_seconds . getDaySeconds ();
206
- const year_day = epoch_day . calculateYearDay ();
207
- const month_day = year_day . calculateMonthDay ();
202
+ const seconds = std.time.epoch.Seconds { .secs = timestamp };
203
+ const days = seconds . getDays ();
204
+ const day_seconds = seconds . getSecondsIntoDay ();
205
+ const year_and_days = days . calculateYearAndDays ();
206
+ const month_and_day = year_and_days . calculateMonthAndDay ();
208
207
209
208
const month_names = [_ ][]const u8 { "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" };
210
209
std .debug .assert (std .time .epoch .Month .jan .numeric () == 1 );
211
210
212
- const month_name = month_names [month_day .month .numeric () - 1 ];
211
+ const month_name = month_names [month_and_day .month .numeric () - 1 ];
213
212
try w .print ("#define __DATE__ \" {s} {d: >2} {d}\" \n " , .{
214
213
month_name ,
215
- month_day .day_index + 1 ,
216
- year_day .year ,
214
+ month_and_day .day_index + 1 ,
215
+ year_and_days .year ,
217
216
});
218
217
try w .print ("#define __TIME__ \" {d:0>2}:{d:0>2}:{d:0>2}\" \n " , .{
219
218
day_seconds .getHoursIntoDay (),
@@ -222,15 +221,15 @@ fn generateDateAndTime(w: anytype, timestamp: u47) !void {
222
221
});
223
222
224
223
const day_names = [_ ][]const u8 { "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" , "Sun" };
225
- const day_name = day_names [@intCast ((epoch_day . day + 3 ) % 7 )];
224
+ const day_name = day_names [@intCast ((days . days + 3 ) % 7 )];
226
225
try w .print ("#define __TIMESTAMP__ \" {s} {s} {d: >2} {d:0>2}:{d:0>2}:{d:0>2} {d}\" \n " , .{
227
226
day_name ,
228
227
month_name ,
229
- month_day .day_index + 1 ,
228
+ month_and_day .day_index + 1 ,
230
229
day_seconds .getHoursIntoDay (),
231
230
day_seconds .getMinutesIntoHour (),
232
231
day_seconds .getSecondsIntoMinute (),
233
- year_day .year ,
232
+ year_and_days .year ,
234
233
});
235
234
}
236
235
0 commit comments