Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions std/assembly/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Date {
let timeString: string;
dateString = dateTimeString.substring(0, posT);
timeString = dateTimeString.substring(posT + 1);

// might end with an offset ("Z", "+05:30", "-08:00", etc.)
for (let i = timeString.length - 1; i >= 0; i--) {
let c = timeString.charCodeAt(i);
Expand All @@ -82,8 +82,8 @@ export class Date {
} else {
let offsetHours = i32.parse(timeString.substring(i + 1));
offsetMs = offsetHours * MILLIS_PER_HOUR;
}
}

if (c == 45) offsetMs = -offsetMs; // negative offset
timeString = timeString.substring(0, i);
break;
Expand Down Expand Up @@ -361,7 +361,8 @@ function dayOfWeek(year: i32, month: i32, day: i32): i32 {
const tab = memory.data<u8>([0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]);

year -= i32(month < 3);
year += floorDiv(year, 4) - floorDiv(year, 100) + floorDiv(year, YEARS_PER_EPOCH);
const century = floorDiv(year >> 2, 100 >> 2);
year += (year >> 2) + (century >> 2) - century;
month = <i32>load<u8>(tab + month - 1);
Comment thread
MaxGraey marked this conversation as resolved.
Outdated
return euclidRem(year + month + day, 7);
}
Expand Down
Loading
Loading