Skip to content

Commit

Permalink
utc dates
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Sep 29, 2024
1 parent 3aa6206 commit 86228f2
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 149 deletions.
8 changes: 5 additions & 3 deletions examples/55_generated/generated_union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,32 @@ const battles = await pokemon.query.battles({
// After checking the __typename, the type is known to be one of the possible battle types
// and TypeScript narrows accordingly.

const dateFormatter = new Intl.DateTimeFormat(`en-US`, { timeZone: `UTC` })

for (const battle of battles) {
switch (battle.__typename) {
case `BattleRoyale`: {
// eslint-disable-next-line
// @ts-ignore-error fixme
const trainers = battle.combatants?.map(_ => _.trainer?.name)
let info = ``
info += `${battle.__typename} on ${new Intl.DateTimeFormat(`en-US`).format(new Date(battle.date ?? 0))}\n`
info += `${battle.__typename} on ${dateFormatter.format(new Date(battle.date ?? 0))}\n`
info += `combatants: ${trainers?.join(`, `) ?? `null`}\n`
info += `winner: ${battle.winner?.name ?? `null`}`
show(info)
break
}
case `BattleTrainer`: {
let info = ``
info += `${battle.__typename} on ${new Intl.DateTimeFormat(`en-US`).format(new Date(battle.date ?? 0))}\n`
info += `${battle.__typename} on ${dateFormatter.format(new Date(battle.date ?? 0))}\n`
info += `${battle.combatant1?.trainer?.name ?? `null`} vs ${battle.combatant2?.trainer?.name ?? `null`}\n`
info += `winner: ${battle.winner?.name ?? `null`}`
show(info)
break
}
case `BattleWild`: {
let info = ``
info += `${battle.__typename} on ${new Intl.DateTimeFormat(`en-US`).format(new Date(battle.date ?? 0))}\n`
info += `${battle.__typename} on ${dateFormatter.format(new Date(battle.date ?? 0))}\n`
info += `trainer: ${battle.trainer?.name ?? `null`} with ${battle.pokemon?.name ?? `null`}\n`
info += `vs wild pokemons: ${battle.wildPokemons?.map(_ => _.name).join(`, `) ?? `null`}\n`
info += `result: ${battle.result ?? `null`}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
headers: Headers {
accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
'content-type': 'application/json',
'x-sent-at-time': '1727567591195'
'x-sent-at-time': '1727568837251'
},
signal: undefined,
method: 'post',
Expand Down
2 changes: 1 addition & 1 deletion examples/__outputs__/20_output/output_envelope.output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
headers: Headers {
'content-type': 'application/graphql-response+json; charset=utf-8',
'content-length': '142',
date: 'Sat, 28 Sep 2024 23:53:11 GMT',
date: 'Sun, 29 Sep 2024 00:13:57 GMT',
connection: 'keep-alive',
'keep-alive': 'timeout=5'
},
Expand Down
6 changes: 3 additions & 3 deletions examples/__outputs__/55_generated/generated_union.output.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---------------------------------------- SHOW ----------------------------------------
BattleWild on 1/12/2020
BattleWild on 1/1/2020
trainer: Ash with Pikachu
vs wild pokemons: Squirtle, Bulbasaur
result: pokemonsCaptured
---------------------------------------- SHOW ----------------------------------------
BattleTrainer on 1/12/2003
BattleTrainer on 1/1/2003
Ash vs Misty
winner: Misty
---------------------------------------- SHOW ----------------------------------------
BattleRoyale on 1/12/1987
BattleRoyale on 1/13/1987
combatants: Ash, Misty
winner: Ash
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'encode',
id: 'a9a6dacc8a222786',
id: 'e4dabd3af63b2f57',
kind: 0,
timestamp: 1727567592222000,
duration: 529.666,
timestamp: 1727568838243000,
duration: 550.75,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -33,14 +33,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'pack',
id: '33c12c20dd81b2c8',
id: 'fabd8bd0776b28f7',
kind: 0,
timestamp: 1727567592224000,
duration: 10972.833,
timestamp: 1727568838246000,
duration: 11052.666,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -57,14 +57,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'exchange',
id: '5abf856952ac07ab',
id: 'adb9ae40a9efa2e6',
kind: 0,
timestamp: 1727567592236000,
duration: 21579.792,
timestamp: 1727568838257000,
duration: 24543.375,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -81,14 +81,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'unpack',
id: '61a5eed3f0de2f87',
id: 'c3f2918fad31578e',
kind: 0,
timestamp: 1727567592257000,
duration: 1204.375,
timestamp: 1727568838282000,
duration: 1198.584,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -105,14 +105,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'decode',
id: '924c8e062fb1e29a',
id: 'bf9bc7a293f29302',
kind: 0,
timestamp: 1727567592259000,
duration: 197,
timestamp: 1727568838284000,
duration: 192.583,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -129,14 +129,14 @@
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: undefined,
traceState: undefined,
name: 'request',
id: '999af1540bcc7bcf',
id: '34963c7854e3930d',
kind: 0,
timestamp: 1727567592221000,
duration: 38085.792,
timestamp: 1727568838243000,
duration: 41029.083,
attributes: {},
status: { code: 0 },
events: [],
Expand Down
2 changes: 1 addition & 1 deletion tests/_/schemas/pokemon/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export namespace DatabaseServer {
{
id: `3`,
type: `BattleRoyale`,
date: new Date(Date.UTC(1987, 0, 1)).getTime(),
date: new Date(Date.UTC(1987, 0, 13)).getTime(),
combatants: [
{ trainerId: `1`, pokemonIds: [`1`, `2`] },
{ trainerId: `2`, pokemonIds: [`3`, `4`] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ console.log(data)
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'encode',
id: 'a9a6dacc8a222786',
id: 'e4dabd3af63b2f57',
kind: 0,
timestamp: 1727567592222000,
duration: 529.666,
timestamp: 1727568838243000,
duration: 550.75,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -64,14 +64,14 @@ console.log(data)
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'pack',
id: '33c12c20dd81b2c8',
id: 'fabd8bd0776b28f7',
kind: 0,
timestamp: 1727567592224000,
duration: 10972.833,
timestamp: 1727568838246000,
duration: 11052.666,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -91,14 +91,14 @@ console.log(data)
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'exchange',
id: '5abf856952ac07ab',
id: 'adb9ae40a9efa2e6',
kind: 0,
timestamp: 1727567592236000,
duration: 21579.792,
timestamp: 1727568838257000,
duration: 24543.375,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -118,14 +118,14 @@ console.log(data)
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'unpack',
id: '61a5eed3f0de2f87',
id: 'c3f2918fad31578e',
kind: 0,
timestamp: 1727567592257000,
duration: 1204.375,
timestamp: 1727568838282000,
duration: 1198.584,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -145,14 +145,14 @@ console.log(data)
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
parentId: '999af1540bcc7bcf',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: '34963c7854e3930d',
traceState: undefined,
name: 'decode',
id: '924c8e062fb1e29a',
id: 'bf9bc7a293f29302',
kind: 0,
timestamp: 1727567592259000,
duration: 197,
timestamp: 1727568838284000,
duration: 192.583,
attributes: {},
status: { code: 0 },
events: [],
Expand All @@ -172,14 +172,14 @@ console.log(data)
}
},
instrumentationScope: { name: 'graffle', version: undefined, schemaUrl: undefined },
traceId: '2522ed6e03c4565a2f498a13e0da0f98',
traceId: '4bdd8c57b66a6f52c0a4007ab958299f',
parentId: undefined,
traceState: undefined,
name: 'request',
id: '999af1540bcc7bcf',
id: '34963c7854e3930d',
kind: 0,
timestamp: 1727567592221000,
duration: 38085.792,
timestamp: 1727568838243000,
duration: 41029.083,
attributes: {},
status: { code: 0 },
events: [],
Expand Down
Loading

0 comments on commit 86228f2

Please sign in to comment.