denostack / superserial

A comprehensive Serializer/Deserializer that can handle any data type.
MIT License
35 stars 3 forks source link

Date() Timezone #9

Closed spendres closed 1 year ago

spendres commented 1 year ago

Have you considered using an ISO Date-Time format to include TZ information, or are you assuming all times are in UTC?

wan2land commented 1 year ago

superserial is designed to be unaffected by timezones. The Date type is not affected by the timezone because it is converting to a timestamp.

For example, the following two times are converted to the same string

serialize(new Date("2023-06-01 09:00:00+09:00")) // Asia/Seoul
// 'Date(1685577600000)'

serialize(new Date("2023-06-01 00:00:00+00:00")) // UTC
// 'Date(1685577600000)'

This string is then converted by the running JavaScript runtime environment to the following format As a result, it follows the timezone of the runtime environment in which it is executed.

const value = new Date(1685577600000)
value.toLocaleString() // your timezone format
spendres commented 1 year ago

Exactly what I needed to hear!

On Mon, Jun 12, 2023 at 9:19 PM Changwan Jun @.***> wrote:

Closed #9 https://github.com/denostack/superserial/issues/9 as completed.

— Reply to this email directly, view it on GitHub https://github.com/denostack/superserial/issues/9#event-9509427228, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEVLYGQYQHKM74AGIEUCHTXK65ZHANCNFSM6AAAAAAZCQVHR4 . You are receiving this because you authored the thread.Message ID: @.***>