diff --git a/app/composables/npm/usePackage.ts b/app/composables/npm/usePackage.ts index 50a40e6c52..a71d8eb566 100644 --- a/app/composables/npm/usePackage.ts +++ b/app/composables/npm/usePackage.ts @@ -37,7 +37,7 @@ export function transformPackument( const timeA = pkg.time[a] const timeB = pkg.time[b] if (!timeA || !timeB) return 0 - return new Date(timeB).getTime() - new Date(timeA).getTime() + return Date.parse(timeB) - Date.parse(timeA) }) .slice(0, RECENT_VERSIONS_COUNT) diff --git a/app/composables/useStructuredFilters.ts b/app/composables/useStructuredFilters.ts index 558368e3a2..f229384d6a 100644 --- a/app/composables/useStructuredFilters.ts +++ b/app/composables/useStructuredFilters.ts @@ -327,7 +327,7 @@ export function useStructuredFilters(options: UseStructuredFiltersOptions) { diff = (a.downloads?.weekly ?? 0) - (b.downloads?.weekly ?? 0) break case 'updated': - diff = new Date(a.package.date).getTime() - new Date(b.package.date).getTime() + diff = Date.parse(a.package.date) - Date.parse(b.package.date) break case 'name': diff = a.package.name.localeCompare(b.package.name) diff --git a/app/pages/search.vue b/app/pages/search.vue index 3b2b478929..b635065aa0 100644 --- a/app/pages/search.vue +++ b/app/pages/search.vue @@ -234,7 +234,7 @@ const displayResults = computed(() => { diff = (a.downloads?.weekly ?? 0) - (b.downloads?.weekly ?? 0) break case 'updated': - diff = new Date(a.package.date).getTime() - new Date(b.package.date).getTime() + diff = Date.parse(a.package.date) - Date.parse(b.package.date) break case 'name': diff = a.package.name.localeCompare(b.package.name) diff --git a/modules/blog.ts b/modules/blog.ts index ee2fd3cd91..3ece7abae8 100644 --- a/modules/blog.ts +++ b/modules/blog.ts @@ -138,7 +138,7 @@ async function loadBlogPosts(blogDir: string, imagesDir: string): Promise new Date(b.date).getTime() - new Date(a.date).getTime()) + posts.sort((a, b) => Date.parse(b.date) - Date.parse(a.date)) return posts } diff --git a/scripts/generate-fixtures.ts b/scripts/generate-fixtures.ts index c176a884d2..fdad17fc4a 100644 --- a/scripts/generate-fixtures.ts +++ b/scripts/generate-fixtures.ts @@ -183,7 +183,7 @@ function slimPackument(pkg: Record): Record { const timeA = time[a] const timeB = time[b] if (!timeA || !timeB) return 0 - return new Date(timeB).getTime() - new Date(timeA).getTime() + return Date.parse(timeB) - Date.parse(timeA) }) .slice(0, RECENT_VERSIONS_COUNT) diff --git a/server/api/atproto/bluesky-comments.get.ts b/server/api/atproto/bluesky-comments.get.ts index 27b330d0d1..bb5208ff5f 100644 --- a/server/api/atproto/bluesky-comments.get.ts +++ b/server/api/atproto/bluesky-comments.get.ts @@ -132,7 +132,7 @@ function parseThread( if (parsed) replies.push(parsed) } } - replies.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()) + replies.sort((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt)) } return { diff --git a/shared/utils/atproto.ts b/shared/utils/atproto.ts index 84625b6555..45f7779973 100644 --- a/shared/utils/atproto.ts +++ b/shared/utils/atproto.ts @@ -15,7 +15,7 @@ const simpleHash = (str: string): number => { // Parse date from frontmatter, add slug-path entropy for same-date collision resolution export const generateBlogTID = (dateString: string, slug: string): string => { - let timestamp = new Date(dateString).getTime() + let timestamp = Date.parse(dateString) if (timestamp % ONE_DAY_MILLISECONDS === 0) { const offset = simpleHash(slug) % 1000000 @@ -28,4 +28,4 @@ export const generateBlogTID = (dateString: string, slug: string): string => { // Using our release date as the tid for the publication export const npmxPublicationRkey = () => - TID.create(new Date('2026-03-03').getTime() * MS_TO_MICROSECONDS, TID_CLOCK_ID) + TID.create(Date.parse('2026-03-03') * MS_TO_MICROSECONDS, TID_CLOCK_ID) diff --git a/test/nuxt/composables/use-package-comparison.spec.ts b/test/nuxt/composables/use-package-comparison.spec.ts index 071e1d354c..bf3710c9b1 100644 --- a/test/nuxt/composables/use-package-comparison.spec.ts +++ b/test/nuxt/composables/use-package-comparison.spec.ts @@ -89,7 +89,7 @@ describe('usePackageComparison', () => { // Should use version-specific timestamp, NOT time.modified expect(values[0]!.display).toBe('2024-06-15T00:00:00.000Z') - expect(values[0]!.raw).toBe(new Date('2024-06-15T00:00:00.000Z').getTime()) + expect(values[0]!.raw).toBe(Date.parse('2024-06-15T00:00:00.000Z')) }) it('stores version-specific time in metadata', async () => { diff --git a/test/unit/app/utils/download-anomalies.spec.ts b/test/unit/app/utils/download-anomalies.spec.ts index f7a00b4c39..745778e35a 100644 --- a/test/unit/app/utils/download-anomalies.spec.ts +++ b/test/unit/app/utils/download-anomalies.spec.ts @@ -22,7 +22,7 @@ function month(monthStr: string, value: number): MonthlyDataPoint { return { value, month: monthStr, - timestamp: new Date(`${monthStr}-01T00:00:00Z`).getTime(), + timestamp: Date.parse(`${monthStr}-01T00:00:00Z`), } } @@ -30,7 +30,7 @@ function year(yearStr: string, value: number): YearlyDataPoint { return { value, year: yearStr, - timestamp: new Date(`${yearStr}-01-01T00:00:00Z`).getTime(), + timestamp: Date.parse(`${yearStr}-01-01T00:00:00Z`), } }