From 3816d4aeada0781cfa617e9776369791e0ee26c0 Mon Sep 17 00:00:00 2001 From: Michael Verschoof Date: Sat, 30 Jan 2021 10:41:34 +0100 Subject: [PATCH] Updated the readme --- README.md | 14 ++++++++++++++ src/lib/prime-time.ts | 7 +++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5090686..522961c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ For example: `primetime(519998462003)` equals the date *1986-6-24 12:01:02.003 G | `primetime().format('{WDD}, {MMMM} {DD}, {YY} @ {HH}:{mm}:{ss} {TZ}', 'nl-nl')` | Format the date to the provided format and user's locale | `dinsdag, juni 24, 1986 @ 12:01:02 UTC` | ### Comparing dates +If the date() | Code | Description | Returns | | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | ------- | @@ -65,6 +66,19 @@ These methods return the updated PrimeTime object, enabling method chaining. | `primetime().clone('day')` | Creates a duplicate PrimeTime object with the year, month and day set | `PrimeTime` | | `primetime().update(519998462003)` | Sets a new timestamp for the object | `PrimeTime` | +### Changing time zones + +| Code | Description | Returns | +| ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | +| `primetime().timezone('Europe/Amsterdam')` | Sets the object as if it is in that timezone | `PrimeTime` | +| `primetime().timezone('Europe/Amsterdam').format('WDD, MMMM, DD, HH, mm, ss, TZZ')` | Format the date (in the chosen time zone) to the provided date parts and user's locale (en-US for example) | `Tuesday, 6/24/1986, 10:01:02 PM Coordinated Universal Time` | +| `primetime().timezone('America/New_York').localise('DD, MM, YY, HH, mm, ss', 'nl-nl', 'Europe/Amsterdam')` | Format the date (in the chosen time zone) to the provided date parts and user's locale (en-US for example) in another time zone | `24-06-1986 18:01:02` | +| `primetime().timezone('Europe/London').after(primetime().timezone('Europe/Amsterdam'))` | Check if the first date is after the second date, using their respective time zones | `true` | +| `primetime().timezone('Europe/London').before(primetime().timezone('Europe/Amsterdam'))` | Check if the first date is before the second date, using their respective time zones | `false` | +| `primetime().timezone('Europe/London').between(primetime().timezone('Europe/Amsterdam'), primetime().timezone('America/New_York'))` | Check if the first date is between the other dates, using their respective time zones | `true` | +| `primetime().timezone('Europe/London').equal(primetime().timezone('Europe/Amsterdam'))` | Check if the first date equals the second date, using their respective time zones | `false` | + + ## Why Prime Time? Named after the [Alan Parsons Project][alan-parsons-project] song [Prime Time][youtube-video] from the album [Ammonia Avenue][ammonia-avenue]. This song is one of my personal favorites and its name fits this project quite well. diff --git a/src/lib/prime-time.ts b/src/lib/prime-time.ts index 1ae18fc..35887b7 100644 --- a/src/lib/prime-time.ts +++ b/src/lib/prime-time.ts @@ -48,7 +48,6 @@ export default class PrimeTime { /* Comparisons */ - // TODO tests with offset (opening hours) difference (to : PrimeTime, timespan? : string | Timespan) : number { const fromTimestamp = Timestamps.offset(this.timestamp, this.offset); const toTimestamp = Timestamps.offset(to.timestamp, to.offset); @@ -92,12 +91,12 @@ export default class PrimeTime { return Format.customise(timestamp, format, locale, timezone); } - utc () : string { + gmt () : string { return Format.gmt(this.timestamp); } - gmt () : string { - return Format.gmt(this.timestamp); + utc () : string { + return this.gmt(); } /* Timezones */