Skip to content

Commit

Permalink
Merge main into experiment-temporal-api
Browse files Browse the repository at this point in the history
  • Loading branch information
meduzen committed Apr 18, 2024
2 parents 7901e9d + b9ef414 commit 8b63f3e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

Nothing for now.

Compare with [last published version](https://github.com/meduzen/datetime-attribute/compare/1.3.3...main).
Compare with [last published version](https://github.com/meduzen/datetime-attribute/compare/1.3.4...main).

## v1.3.4 (2024-04-18)

Compare with [previous version](https://github.com/meduzen/datetime-attribute/compare/1.3.3...1.3.4).

### Fixed

- Fix incorrect year for `datetime(date, 'week')` when the week started the previous year. For example, `2021-01-01` is a Friday and its week belongs to 2020 (as [per spec](./README.md#weeknumber)). In that case, the output was `2021-53` instead of `2020-53`.
- Fix incorrect year for `datetime(date, 'week')` when the week started the previous year. For example, `2021-01-01` is a Friday and its week belongs to 2020 (as [per spec](./README.md#weeknumber)). In that case, the output was `2021-W53` instead of `2020-W53`.

### Improved

- Improve type definitions where `?` and `undefined` are redundant by removing `undefined`:
- for some signatures of optional parameters from `datetime(date?: Date | undefined` to `datetime(date?: Date`
- for some optional properties from `{ w?: number | undefined }` to `{ w?: number }`

### Documentation

- Use brotli compression instead of gzip one to express the module size.

### Under the hood

- Enforce type definitions for optional properties of the internal config functions `setConfig` and `setTzConfig`: it was possible to omit their `separator` property, it’s not anymore.
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
Get a [`datetime` attribute](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement/datetime) for HTML `<time>` (and [other elements](#not-only-in-time)).

It covers the [whole WHATWG specification](https://html.spec.whatwg.org/multipage/text-level-semantics.html#attr-time-datetime) in 4 functions:
- [**`datetime()`**](#expressing-moments-with-datetime) for a specific moment ([645 B compressed](https://bundlejs.com/?q=datetime-attribute&treeshake=[{datetime}]&bundle));
- [**`datetimeTz()`**](#adding-a-timezone-offset-to-a-moment-with-datetimetz) for a specific moment in a given timezone ([942 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{datetimeTz}]&bundle));
- [**`duration()`**](#expressing-durations-with-duration) for a duration ([307 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{duration}]&bundle));
- [**`tzOffset()`**](#expressing-timezone-offsets-with-tzoffset) for a timezone offset ([388 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{tzOffset}]&bundle)).
- [**`datetime()`**](#expressing-moments-with-datetime) for a specific moment ([641 B compressed](https://bundlejs.com/?q=datetime-attribute&treeshake=[{datetime}]&config={"compression"%3A"brotli"}&bundle));
- [**`datetimeTz()`**](#adding-a-timezone-offset-to-a-moment-with-datetimetz) for a specific moment in a given timezone ([903 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{datetimeTz}]&config={"compression"%3A"brotli"}&bundle));
- [**`duration()`**](#expressing-durations-with-duration) for a duration ([284 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{duration}]&config={"compression"%3A"brotli"}&bundle));
- [**`tzOffset()`**](#expressing-timezone-offsets-with-tzoffset) for a timezone offset ([332 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{tzOffset}]&config={"compression"%3A"brotli"}&bundle)).

Additionally, a [`DateTime` class](#the-datetime-class) ([721 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{DateTime}]&bundle)) and some [other functions](#other-functions) are provided.
Additionally, a [`DateTime` class](#the-datetime-class) ([710 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{DateTime}]&config={"compression"%3A"brotli"}&bundle)) and some [other functions](#other-functions) are provided.

[![Node.js CI](https://github.com/meduzen/datetime-attribute/actions/workflows/node.js.yml/badge.svg)](https://github.com/meduzen/datetime-attribute/actions/workflows/node.js.yml)

The package is lightweight ([~ 1.42 KB compressed](https://bundlejs.com/?q=datetime-attribute&bundle) for `import *`), tree-shakeable, typed and tested.
The package is lightweight ([~ 1.37 KB compressed](https://bundlejs.com/?q=datetime-attribute&config={"compression"%3A"brotli"}&bundle) for `import *`), tree-shakeable, typed and tested.

## Table of contents

Expand Down Expand Up @@ -419,7 +419,7 @@ daysBetween(january1st2021, january11th) // 10
daysBetween(january19th, january11th) // -8
```

([134 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{daysBetween}]&bundle))
([110 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{daysBetween}]&config={"compression"%3A"brotli"}&bundle))

### `weekNumber()`

Expand All @@ -442,7 +442,7 @@ weekNumber(january1st2021) // 53: it’s a Friday!
weekNumber(january11th) // 2
```

([201 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{weekNumber}]&bundle))
([183 B](https://bundlejs.com/?q=datetime-attribute&treeshake=[{weekNumber}]&config={"compression"%3A"brotli"}&bundle))

## Changelog

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datetime-attribute",
"version": "1.3.3",
"version": "1.3.4",
"description": "Generate datetime attributes for the <time> HTML element, following WHATWG and ISO8601 specs.",
"type": "module",
"sideEffects": false,
Expand Down

0 comments on commit 8b63f3e

Please sign in to comment.