Skip to content

Commit

Permalink
refactor: remove toEpochSeconds() method
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Aug 4, 2023
1 parent ea0b51c commit ad992c3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
6 changes: 0 additions & 6 deletions CalendarDate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,6 @@ Deno.test("toEpochMs", () => {
assertEquals(D`1969-12-31`.toEpochMs(), -86400 * 1000);
});

Deno.test("toEpochSeconds", () => {
assertEquals(D`1970-01-01`.toEpochSeconds(), 0);
assertEquals(D`1970-01-02`.toEpochSeconds(), 86400);
assertEquals(D`1969-12-31`.toEpochSeconds(), -86400);
});

Deno.test("toDate()", async (t) => {
for (
const dateStr of [
Expand Down
6 changes: 1 addition & 5 deletions CalendarDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class CalendarDate {
}
return optimizedDaysInMonth(month);
}

/**
* Is 'year' a leap year? Can be an absolute year (e.g. 2016) or relative to the year 2000 (e.g. 16) or relative to the "year 0" (1 BCE).
* @param {number} year - The year in question
Expand All @@ -231,11 +232,6 @@ class CalendarDate {
return (this.#value - 719528) * 86400_000; // 719528 is the unix epoch, CalendarDate.fromString("1970-01-01").value
}

/** Get the number of seconds since the Unix epoch (Jan 1, 1970 UTC) */
public toEpochSeconds(): number {
return (this.#value - 719528) * 86400; // 719528 is the unix epoch, CalendarDate.fromString("1970-01-01").value
}

public static fromDate(d: Date): CalendarDate {
const isoString = d.toISOString();
if (!isoString.endsWith("00:00:00.000Z")) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ calendar in use at the time.
Dates are internally represented as a single `Number` for performance and memory
efficiency.

This is a tiny single-file library with no dependencies and is under 3 kB when
This is a tiny single-file library with no dependencies and is under 2.9 kB when
minified.

## Why do you want this?
Expand Down

0 comments on commit ad992c3

Please sign in to comment.