Fiks: bruk SDK sin toISOString()/toDate() for timestamps i stedet for microsSinceEpoch
microsSinceEpoch var feil propertynavn — SDK bruker __timestamp_micros_since_unix_epoch__. Bruker nå SDK-metodene direkte som er framtidssikre. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
69b1cb4221
commit
4001c05648
1 changed files with 2 additions and 5 deletions
|
|
@ -26,9 +26,7 @@ export function createSpacetimeChat(
|
|||
function spacetimeRowToMessage(row: any): MessageData {
|
||||
let createdAt: string;
|
||||
try {
|
||||
const micros = row.createdAt?.microsSinceEpoch;
|
||||
const ms = typeof micros === 'bigint' ? Number(micros / 1000n) : Number(micros) / 1000;
|
||||
createdAt = new Date(ms).toISOString();
|
||||
createdAt = row.createdAt?.toISOString?.() ?? row.createdAt?.toDate?.()?.toISOString() ?? new Date().toISOString();
|
||||
} catch {
|
||||
createdAt = new Date().toISOString();
|
||||
}
|
||||
|
|
@ -117,8 +115,7 @@ export function createSpacetimeChat(
|
|||
|
||||
function extractMs(ts: any): number {
|
||||
try {
|
||||
const micros = ts?.microsSinceEpoch;
|
||||
return typeof micros === 'bigint' ? Number(micros / 1000n) : Number(micros) / 1000;
|
||||
return ts?.toDate?.()?.getTime() ?? 0;
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue