MCPcopy Create free account
hub / github.com/apache/fory / write

Method write

javascript/packages/core/lib/gen/datetime.ts:99–108  ·  view source on GitHub ↗
(accessor: string)

Source from the content-addressed store, hash-verified

97 }
98
99 write(accessor: string): string {
100 const epoch = this.scope.declareByName("epoch", `new Date("1970/01/01 00:00").getTime()`);
101 return `
102 if (${accessor} instanceof Date) {
103 ${this.builder.writer.writeVarInt64(`Math.floor((${accessor}.getTime() - ${epoch}) / 1000 / (24 * 60 * 60))`)}
104 } else {
105 ${this.builder.writer.writeVarInt64(`Math.floor((${accessor} - ${epoch}) / 1000 / (24 * 60 * 60))`)}
106 }
107 `;
108 }
109
110 read(accessor: (expr: string) => string): string {
111 const epoch = this.scope.declareByName("epoch", `new Date("1970/01/01 00:00").getTime()`);

Callers

nothing calls this directly

Calls 2

declareByNameMethod · 0.80
writeVarInt64Method · 0.45

Tested by

no test coverage detected