From 9c852cdfd28da06763e14dcd5b2fac1b8fd9b9bf Mon Sep 17 00:00:00 2001 From: Vincent LE GOFF Date: Mon, 13 May 2019 20:03:24 +0200 Subject: [PATCH] datetime: timezone fix in toIMF (denoland/deno_std#400) Original: https://github.com/denoland/deno_std/commit/49ae9439f71228326c1328d89502e437c00928fc --- datetime/mod.ts | 2 +- datetime/test.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/datetime/mod.ts b/datetime/mod.ts index 4d627fcbeedaf2..1fd3b348fb6bd6 100644 --- a/datetime/mod.ts +++ b/datetime/mod.ts @@ -140,7 +140,7 @@ export function toIMF(date: Date): string { "Nov", "Dec" ]; - return `${days[date.getDay()]}, ${d} ${ + return `${days[date.getUTCDay()]}, ${d} ${ months[date.getUTCMonth()] } ${y} ${h}:${min}:${s} GMT`; } diff --git a/datetime/test.ts b/datetime/test.ts index f4791472849d44..2c34e4fe80c022 100644 --- a/datetime/test.ts +++ b/datetime/test.ts @@ -83,3 +83,12 @@ test({ assertEquals(actual, expected); } }); + +test({ + name: "[DateTime] to IMF 0", + fn(): void { + const actual = datetime.toIMF(new Date(0)); + const expected = "Thus, 01 Jan 1970 00:00:00 GMT"; + assertEquals(actual, expected); + } +});