Skip to content

Commit 49003b2

Browse files
authored
Add explicit timeout for retrieving timezone data. Update docs. (#9)
* Add explicit timeout for retrieving timezone data. * Documentation updates.
1 parent d459a3d commit 49003b2

4 files changed

Lines changed: 147 additions & 61 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# @tubular/time
22

3-
Not all days are 24 hours. Some are 23 hours, or 25, or even 23.5 or 24.5 or 47 hours. How about a Thursday followed directly by a Saturday, giving Friday the slip? Or a September only 19 days long? This is a date/time library for handling both day-to-day situations (so to speak) and some weird ones too.
3+
Not all days are 24 hours. Some are 23 hours, or 25, or even 23.5 or 24.5 or 47 hours. Some minutes are 61 seconds long. How about a Thursday followed directly by a Saturday, giving Friday the slip? Or a September only 19 days long? This is a date/time library for handling both day-to-day situations (so to speak) and some weird ones too.
44

55
[![npm](https://img.shields.io/npm/v/@tubular/time.svg)](https://www.npmjs.com/package/@tubular/time/) [![Build Status](https://img.shields.io/travis/kshetline/tubular_time/master.svg)](https://travis-ci.com/github/kshetline/tubular_time/) [![Coverage Status](https://coveralls.io/repos/github/kshetline/tubular_time/badge.svg?branch=master)](https://coveralls.io/github/kshetline/tubular_time) [![npm downloads](https://img.shields.io/npm/dm/@tubular/time.svg)](https://npmjs.org/package/@tubular/time/) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@tubular/time) ![license](https://img.shields.io/badge/licence-mit-informational)
66

77
## Key features<!-- omit in toc -->
88

99
* Mutable and immutable DateTime objects supporting the Gregorian and Julian calendar systems, with settable crossover.
1010
* IANA timezone support, with features beyond formatting using timezones, such as parsing, accessible listings of all available timezones (single-array list, grouped by UTC offset, or grouped by region), and live updates of timezone definitions.
11-
* Support for leap seconds and conversions between TAI (International Atomic Time) and UTC (Universal Coordinated Time).
11+
* Supports leap seconds and conversions between TAI (International Atomic Time) and UTC (Universal Coordinated Time).
1212
* Supports and recognizes negative Daylight Saving Time.
1313
* Extensive date/time manipulation and calculation capabilities.
1414
* Many features available using a familiar Moment.js-style API.
15-
* Astronomical time conversions among TDT (Terrestrial Dynamic Time), UT1, UTC and TAI, as well as local mean time, by geographic longitude, to one minute (of time) resolution.
15+
* Astronomical time conversions among TDT (Terrestrial Dynamic Time), UT1, UTC and TAI.
16+
* Local mean time, by geographic longitude, to one minute (of time) resolution.
1617
* Astronomical time conversions among TDT (Terrestrial Dynamic Time), UT1, UTC and TAI, as well as local mean time, by geographic longitude, to one minute (of time) resolution.
1718
* Internationalization via JavaScript’s `Intl` Internationalization API, with additional built-in i18n support for issues not covered by `Intl`, and US-English fallback for environments without `Intl` support.
1819
* Package suitable for tree shaking and Angular optimization.
@@ -24,7 +25,7 @@ Not all days are 24 hours. Some are 23 hours, or 25, or even 23.5 or 24.5 or 47
2425

2526
This library was originally developed for an astronomy website, <https://skyviewcafe.com>, and has some features of particular interest for astronomy and historical events, but has been expanded to provide many features similar to the now-legacy-status Moment.js.
2627

27-
Unlike Moment.js, IANA timezone handling is built in, not a separate module, with a compact set of timezone data that reaches roughly five years into the past and five years into the future, expanded into the past and future using Daylight Saving Time rules and/or values extracted from `Intl.DateTimeFormat`. Unlike the `Intl` API, the full list of available timezones is exposed, facilitating the creation of timezone selection interfaces.
28+
Unlike Moment.js, IANA timezone handling is built in, not a separate module, with a compact set of timezone definitions that reach roughly five years into the past and five years into the future, expanded into the past and future using Daylight Saving Time rules and/or values extracted from `Intl.DateTimeFormat`. Unlike the `Intl` API, the full list of available timezones is exposed, facilitating the creation of timezone selection interfaces.
2829

2930
Two alternate large timezone definition sets, of approximately 280K each, are available, each serving slightly different purposes. These definitions can be bundled at compile time, or loaded dynamically at run time. You can also download live updates when the IANA Time Zone Database is updated.
3031

@@ -535,15 +536,15 @@ When you use the add/subtract/roll/set methods on a locked instance, a new modif
535536

536537
### Using `add` (and `subtract`)
537538

538-
The `add()` method is the main method here. `subtract()` is nothing more than a convenience method which negates the amount being added, and then calls `add()`, so I will speak of this going forward in terms of the `add()` method alone.
539+
> `subtract()` is nothing more than a convenience method which negates the amount being added, and then calls `add()`. The documentation that follows is in terms of the `add()` method alone, but applies, with this negation, to the `subtract()` method as well.
539540

540541
An example of using `add()`:
541542

542543
`ttime().add('year', 1)` or `ttime().add(DateTimeField.YEAR, 1)`
543544

544545
The above produces a date one year later than the current time. In most cases, this means that the resulting date has the same month and date, but in the case of a leap day:
545546

546-
`ttime('2024-02-29').add('year', 1)..toIsoString(10)``2025-02-28`
547+
`ttime('2024-02-29').add('year', 1).toIsoString(10)``2025-02-28`
547548

548549
...the date is pinned to 28 so that an invalid date is not created. Similarly, when adding months, invalid dates are prevented:
549550

@@ -577,13 +578,13 @@ Even with the default behavior, however, it is still possible for hours and minu
577578

578579
### Using `roll()`
579580

580-
You can use the `roll()` method tospinthrough values for each date/time field. This can be used, for example, in a user interface where you select a field and use up/down arrows to change the value, and the value changes in a wrap-around fashion, e.g. ...58 → 59 → 00 → 01..., etc.
581+
You can use the `roll()` method to roll, or spin, through values for each date/time field. This operation can be used, for example, in a user interface where you select a field and use up/down arrows to change the value, and the value changes in a wrap-around fashion, e.g. ...58 → 59 → 00 → 01..., etc.
581582

582583
While seconds and minutes wrap at 59, hours at 23, and dates wrap at the length of the current month, there are no natural wrapping boundaries for years. The wrap-range defaults to 1900-2099, but you can pass optional arguments to change this range (this only effects rolling of years, not other time units).
583584

584585
You can `roll` using the following fields: `MILLI`, `SECOND`, `MINUTE`, `HOUR`, `AM_PM`, `DAY`, `DAY_OF_WEEK`, `DAY_OF_WEEK_LOCALE`, `DAY_OF_YEAR`, `WEEK`, `WEEK_LOCALE`, `MONTH`, `YEAR`, `YEAR_WEEK`, `YEAR_WEEK_LOCALE`, `ERA`.
585586

586-
For the purpose of the `roll()` method, `AM_PM` and `ERA` are treated as numeric values. AM and BC are 0, PM and AD are 1. If you roll by an odd number, the value will be changed. If you roll by an even value, the value will be unchanged.
587+
For the purpose of the `roll()` method, `AM_PM` and `ERA` are treated as numeric values. AM and BC are 0, PM and AD are 1. If you roll by an odd number, the value will be changed. If you roll by an even value, the value will remain unchanged.
587588

588589
Examples of using `roll()`:
589590

@@ -845,7 +846,7 @@ In December 2011, the nation of Samoa jumped over the International Dateline (or
845846
]
846847
```
847848

848-
Heres what that month looks like, as rendered by the drop-time date picker at skyviewcafe.com:
849+
Heres what that month looks like, as rendered by the drop-down date picker at skyviewcafe.com:
849850

850851
<img src="https://shetline.com/readme/tubular-time/2.4.0/apia_dec_2011_cal.jpg" width=185 height=150 alt="Apia Dec 2011">
851852

package-lock.json

Lines changed: 129 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)