From d316a81d115d8f04ecbd45c5d827542bdf28744d Mon Sep 17 00:00:00 2001 From: Mahmoud Moravej <55846417+mahmoudmoravej@users.noreply.github.com> Date: Fri, 26 Jun 2020 14:26:11 -0400 Subject: [PATCH 1/2] Correct documents Bring applyTimeZoneOffset and unapplyTimeZoneOffset results as code comment. Also correct the unapplyTimeZoneOffset example --- packages/dates/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/dates/README.md b/packages/dates/README.md index aa6b747495..f6a66cc0a0 100644 --- a/packages/dates/README.md +++ b/packages/dates/README.md @@ -27,7 +27,7 @@ const date = new Date('2018-06-01Z14:00'); const timeZone1 = 'Australia/Perth'; const timeZone2 = 'America/Toronto'; -const newDate = applyTimeZoneOffset(date, timeZone1, timeZone2); +const newDate = applyTimeZoneOffset(date, timeZone1, timeZone2); //'2018-06-01T02:00:00.000Z' ``` ### `formatDate` @@ -330,7 +330,8 @@ Takes in a date object and two optional time zone string parameters. Returns a n import {unapplyTimeZoneOffset} from '@shopify/dates'; const date = new Date('2018-06-01Z14:00'); -const timeZone = 'Australia/Perth'; +const timeZone1 = 'Australia/Perth'; +const timeZone2 = 'America/Toronto'; -const newDate = unapplyTimeZoneOffset(date, offset); +const newDate = unapplyTimeZoneOffset(date, timeZone1, timeZone2); //2018-06-02T02:00:00.000Z ``` From c3c9515401363ec46d082fca264108f65b776cb7 Mon Sep 17 00:00:00 2001 From: Mahmoud Moravej <55846417+mahmoudmoravej@users.noreply.github.com> Date: Fri, 26 Jun 2020 15:19:05 -0400 Subject: [PATCH 2/2] Update README.md --- packages/dates/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/dates/README.md b/packages/dates/README.md index f6a66cc0a0..4e8f62ce3c 100644 --- a/packages/dates/README.md +++ b/packages/dates/README.md @@ -18,7 +18,7 @@ Optional time zone parameters that are omitted are inferred as local. ### `applyTimeZoneOffset` -Takes in a date object and two optional time zone string parameters. Returns a new date object with the offset between the time zones added to it. +Takes in a date object and two optional time zone string parameters. Returns a new date object with the offset between the time zones added to it. We can also assume the passed date is in the first time zone and we want to calculate it in the second time zone. ```ts import {applyTimeZoneOffset} from '@shopify/dates'; @@ -324,7 +324,7 @@ const { ### `unapplyTimeZoneOffset` -Takes in a date object and two optional time zone string parameters. Returns a new date object with the offset between the time zones subtracted from it. +Takes in a date object and two optional time zone string parameters. Returns a new date object with the offset between the time zones subtracted from it. We can also assume the passed date is in the second time zone and we want to calculate it back in the first time zone. ```ts import {unapplyTimeZoneOffset} from '@shopify/dates';