Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion app/composables/npm/usePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion app/composables/useStructuredFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function loadBlogPosts(blogDir: string, imagesDir: string): Promise<BlogPo
}

// Sort newest first
posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
posts.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))
return posts
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function slimPackument(pkg: Record<string, unknown>): Record<string, unknown> {
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)

Expand Down
2 changes: 1 addition & 1 deletion server/api/atproto/bluesky-comments.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions shared/utils/atproto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion test/nuxt/composables/use-package-comparison.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/app/utils/download-anomalies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ 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`),
}
}

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`),
}
}

Expand Down
Loading