ui changes and cs prices
All checks were successful
Test and deploy staging / staging (push) Successful in 11m52s
All checks were successful
Test and deploy staging / staging (push) Successful in 11m52s
This commit is contained in:
23
src/lib/cs-prices/steam.ts
Normal file
23
src/lib/cs-prices/steam.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/** Parse the English UTC labels returned by Steam's market history endpoint. */
|
||||
export function steamDate(value: string): string {
|
||||
const match = /^(\w{3}) (\d{1,2}) (\d{4})(?: (\d{1,2}):)?/.exec(value);
|
||||
if (!match) throw new Error(`Unknown Steam date: ${value}`);
|
||||
const month = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec'
|
||||
].indexOf(match[1]);
|
||||
if (month < 0) throw new Error(`Unknown Steam month: ${value}`);
|
||||
return new Date(
|
||||
Date.UTC(Number(match[3]), month, Number(match[2]), Number(match[4] ?? 0))
|
||||
).toISOString();
|
||||
}
|
||||
Reference in New Issue
Block a user