From ed96519a1023c441bb08137bfccad7ea53b6b754 Mon Sep 17 00:00:00 2001 From: David Duwaer Date: Fri, 26 Nov 2021 12:39:49 +0100 Subject: [PATCH 1/3] Fixed spacings around diagram in readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4f62c5b..66631d5 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,12 @@ npm install globol # How to use This library consists mainly of a few smart data types that each describe a different concept of time. This is what they are and how they relate to eachother: +
+

+
You can create instances of any one of them with static methods from their classes, e.g. `Instant.from(...)`, `Instant.parse(...)` or `LocalTime.browser()`. Similar methods exist on all Globol data types. From 1592195b004dc21732fc3d54538139698b68b5fc Mon Sep 17 00:00:00 2001 From: David Duwaer Date: Fri, 26 Nov 2021 12:43:27 +0100 Subject: [PATCH 2/3] Fixed inline code formatting in readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 66631d5..7441035 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,13 @@ npm install globol # How to use This library consists mainly of a few smart data types that each describe a different concept of time. This is what they are and how they relate to eachother: -
-
+
+

-
+
+ You can create instances of any one of them with static methods from their classes, e.g. `Instant.from(...)`, `Instant.parse(...)` or `LocalTime.browser()`. Similar methods exist on all Globol data types. From 6d9e910f0b4bd16b60eb7eb6609e48d60d81d760 Mon Sep 17 00:00:00 2001 From: David Duwaer Date: Fri, 3 Dec 2021 14:09:45 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7441035..38ca564 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,33 @@ npm install globol ``` # How to use +Get the current timestamp +```typescript +import {Instant} from 'globol'; + +Instant.now() // returns an Instant +``` +All types and functions are in the `globol` module, so we'll leave the import statement out from now. +You can also use a shorthand for the current time: + +```typescript +now() // returns an Instant +``` + +Get "tomorrow, in this timezone" +```typescript +const tomorrow = now() + .atZone(TimeZone.browser()) + .toLocalDate() + .plus({days: 1}); +``` + +Get the current time on the clock (e.g. '14:57') in Berlin +```typescript +now() // a timestamp + .atZone('Europe/Berlin') // returns a ZonedDateTime: the timestamp represented in this zone + .toLocalTime() // returns a LocalTime, e.g. '14:57' +``` This library consists mainly of a few smart data types that each describe a different concept of time. This is what they are and how they relate to eachother:
@@ -74,24 +101,6 @@ A fixed length of physical time. ### ZoneId & ZoneOffset These represent timezones. The difference between ZoneId and ZoneOffset is as follows: ZoneId represents something like `Europe/Amsterdam`, which can have a `ZoneOffset` of +1 in the winter and +2 in the summer. -# Usage examples -Get the current timestamp -```typescript -Instant.now() // returns an Instant -``` - -Or use the shorthand -```typescript -now() // returns an Instant -``` - -Get the current time on the clock (e.g. '14:57') in Berlin -```typescript -now() // a timestamp - .atZone('Europe/Berlin') // returns a ZonedDateTime: the timestamp represented in this zone - .toLocalTime() // returns a LocalTime, e.g. '14:57' -``` - # Future work ## Time zone information Browsers provide time zone information, but the support is still limited/incomplete. Therefore we'd like to make it optional to include the moment-timezone dependency. This can be done by make a separate NPM dependency called `globol-timezone` which, when included, runtime-enriches Globol with the `moment-timezone` time zone information. When it's left out globol would rely on the time zone information supplied by the browser.