Skip to content
Draft
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
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default tseslint.config(
'src/components/**',
'src/config.ts',
'src/data/**',
'src/lib/umbraco/*ApiSchema.d.ts',
'src/serverConfig.ts',
'src/util.ts',
],
Expand Down
2 changes: 1 addition & 1 deletion generateUmbracoApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function main() {
const outputAst = await openapiTS(url.toString());

await fs.promises.writeFile(
path.join(__dirname, 'src', 'data', 'umbraco', outputFile),
path.join(__dirname, 'src', 'lib', 'umbraco', outputFile),
astToString(outputAst),
);
}),
Expand Down
24 changes: 0 additions & 24 deletions src/data/umbraco/client.ts

This file was deleted.

File renamed without changes.
17 changes: 13 additions & 4 deletions src/data/parseUtcAsCst.ts → src/lib/date.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { TZDate } from '@date-fns/tz';
import { CST_TZ } from '@/config';
import { TZDate, tz } from '@date-fns/tz';
import { format } from 'date-fns';
import { CST_TZ } from '#lib/config.ts';

// Umbraco doesn't save dates with timezone information so we have to manually fix it
// Umbraco stores Chicago-local date parts without reliable zone data. Interpret
// the parts in America/Chicago, then return a plain Date instant so SvelteKit can
// serialize load data without custom transport hooks.
export function parseUtcAsCst(dateStr: string): Date {
const match = dateStr.match(
/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,7}))?)?)?(?:Z|[+-]\d{2}:\d{2})?$/,
Expand Down Expand Up @@ -32,7 +35,7 @@ export function parseUtcAsCst(dateStr: string): Date {
(millisecondStr ?? '0').slice(0, 3).padEnd(3, '0'),
);

return new TZDate(
const parsed = new TZDate(
year,
month,
day,
Expand All @@ -42,4 +45,10 @@ export function parseUtcAsCst(dateStr: string): Date {
millisecond,
CST_TZ,
);

return new Date(parsed.getTime());
}

export function formatDate(date: Date | string, formatStr: string): string {
return format(date, formatStr, { in: tz(CST_TZ) });
}
File renamed without changes.
Loading
Loading