Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/workflows/check-published-scheduled.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Check Published

on:
workflow_dispatch:
schedule:
- cron: '30 20 * * *'

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,37 @@ available functionality as of v3.6.0.
Additionally, the [`date-fns-tz`](https://github.com/marnusw/date-fns-tz) library is included. Contains all
available functionality as of v1.3.7 except that the code in `fp` folder is excluded, which contains functional programming related stuff that is not used at the moment.

### `formatUtc`
## `formatUtc`

The `formatUtc` function is a wrapper around `date-fns-tz`'s `format` function, but with the following differences:

- There is no `options` argument, `timeZone` is always UTC.

Generally speaking, `formatUtc` should be used in place of `format` or `tzFormat`, unless non-UTC time zones are required.

### Important note about `Instant.toString()`
## Important note about `Instant.toString()`

Unlike built-in `Date.toISOString()`, `Instant.toString()` will not add fractional second digits if those values are zero.

E.g.

```
new Date(0).toISOString() -> 1970-01-01T00:00:00.100Z
```ts
new Date(0).toISOString(); // -> 1970-01-01T00:00:00.100Z

vs
/* vs */

Temporal.Instant(0n).toString() -> 1970-01-01T00:00:00.1Z
Temporal.Instant(0n).toString(); // -> 1970-01-01T00:00:00.1Z
```

### Why not just use the polyfill?
## Why not just use the polyfill?

The polyfill is not production ready. The implementation is designed to be used in the browser so cannot make use of Node's high-resolution timer to more accurately simulate nanosecond precision time. Crucially, the polyfill does not guarantee always increasing nanosecond precision times on subsequent calls, which makes it a non-starter for recording the time of events in production webservices.

### Installing and usage
## Installing and usage

`npm install @checkdigit/time` then:

```
```ts
import { Temporal } from '@checkdigit/time'; // delete this once Temporal becomes a built-in

// print out nanosecond-precision ISO8601 datetime
Expand All @@ -61,13 +61,13 @@ console.log('Current time', Temporal.Now.instant().toString());

For `date-fns` functionality:

```
```ts
import { formatUtc } from '@checkdigit/time';

console.log(formatUtc(new Date(), 'yyyy-MM-dd'));
```

### Documentation
## Documentation

The stage 3 proposal can be found here: https://github.com/tc39/proposal-temporal

Expand All @@ -77,7 +77,7 @@ The documentation for `date-fns` is here: https://date-fns.org/

The documentation for `date-fns-tz` is here: https://github.com/marnusw/date-fns-tz

### Maintenance notes:
## Maintenance notes:

When updating the latest code from the original repositories, except making all the necessary changes to make them fully typescript compatible, please remember to carry over the patches to overcome the following issues:

Expand Down
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@checkdigit/eslint-config';
Loading
Loading