alexandercerutti / passkit-generator

The easiest way to generate custom Apple Wallet passes in Node.js
MIT License
873 stars 108 forks source link

Fix Date to W3C string converter #155

Closed JensSpanier closed 1 year ago

JensSpanier commented 1 year ago

Description

Currently date conversion is not handled right if the timezone is different to UTC (Z).

Example: I live in Germany (currently UTC+02:00). So if my local time is 12:00, it's 10:00 in UTC. The correct representation of this time as W3C (ISO 8601) string is 2023-08-08T10:00:00Z or 2023-08-08T12:00:00+02:00.

But if I call dateToW3CString with a date created with new Date() it's converted to 2023-08-08T12:00:00Z. But thats 14:00 in my timezone. With toISOString it's correctly 2023-08-08T10:00:00.000Z.

So instead of using this complex and incorrect way to convert a Date to a W3C (ISO 8601) string, we should use the built-in function toISOString.

Check relevant checkboxes

alexandercerutti commented 1 year ago

Hey @JensSpanier, thank you for your PR! I'll take a deep look at it very soon, but at a first look, it looks already promising!

In the meanwhile I'd like to thank you for your contribution!

alexandercerutti commented 1 year ago

Released in v3.1.0 🎉 Thank you very much @JensSpanier !