Skip to content

Commit

Permalink
use Temporal.PlainDate.from
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Mar 15, 2024
1 parent 4977e54 commit 9aedf90
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions web_src/js/webcomponents/absolute-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ window.customElements.define('absolute-date', class extends HTMLElement {
this.ownerDocument.documentElement.getAttribute('lang') ||
'';

// only extract the first 10 characters, e.g. the `yyyy-mm-dd` part
const [isoYear, isoMonth, isoDate] = this.getAttribute('date').substring(0, 10).split('-');
const plainDate = new Temporal.PlainDate(isoYear, isoMonth, isoDate);
// only use the first 10 characters, e.g. the `yyyy-mm-dd` part
const plainDate = Temporal.PlainDate.from(this.getAttribute('date').substring(0, 10));
if (!this.shadowRoot) this.attachShadow({mode: 'open'});
this.shadowRoot.textContent = plainDate.toLocaleString(lang ?? [], {
...(year && {year}),
Expand Down

0 comments on commit 9aedf90

Please sign in to comment.