Skip to content

Commit badd089

Browse files
committed
Serialize Timestamps as string (per proto3 JSON format).
1 parent 8c2bbc3 commit badd089

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/firestore/src/remote/serializer.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,15 @@ export class JsonProtoSerializer {
207207
* to actually return a Timestamp proto.
208208
*/
209209
private toTimestamp(timestamp: Timestamp): string {
210-
return {
211-
seconds: '' + timestamp.seconds,
212-
nanos: timestamp.nanoseconds
213-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
214-
} as any;
210+
if (this.options.useProto3Json) {
211+
return timestamp.toDate().toISOString();
212+
} else {
213+
return {
214+
seconds: '' + timestamp.seconds,
215+
nanos: timestamp.nanoseconds
216+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
217+
} as any;
218+
}
215219
}
216220

217221
private fromTimestamp(date: string | TimestampProto): Timestamp {

0 commit comments

Comments
 (0)