Skip to content

Instantly share code, notes, and snippets.

@mbbx6spp
Last active October 14, 2024 14:16
Show Gist options
  • Select an option

  • Save mbbx6spp/aa6bde911b889e8ef5672a89c130d227 to your computer and use it in GitHub Desktop.

Select an option

Save mbbx6spp/aa6bde911b889e8ef5672a89c130d227 to your computer and use it in GitHub Desktop.

Revisions

  1. mbbx6spp revised this gist Oct 14, 2024. No changes.
  2. mbbx6spp revised this gist Oct 14, 2024. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions stdout
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    ┌───────┬───────┬───────────────┐
    │ (idx) │ value │ Values │
    ├───────┼───────┼───────────────┤
    │ 0 │ │ "2024-10-14~" │
    │ 1 │ │ 1728864000000 │
    │ 2 │ │ 1728950399999 │
    │ 3 │ 255 │ │
    │ 4 │ 0 │ │
    │ 5 │ │ true │
    │ 6 │ │ true │
    │ 7 │ │ false │
    └───────┴───────┴───────────────┘
    ┌───────┬───────┬───────────────┐
    │ (idx) │ value │ Values │
    ├───────┼───────┼───────────────┤
    │ 0 │ │ "2024-10-14?" │
    │ 1 │ │ 1728864000000 │
    │ 2 │ │ 1728950399999 │
    │ 3 │ 0 │ │
    │ 4 │ 255 │ │
    │ 5 │ │ true │
    │ 6 │ │ true │
    │ 7 │ │ false │
    └───────┴───────┴───────────────┘
    ┌───────┬─────────────────────────┐
    │ (idx) │ Values │
    ├───────┼─────────────────────────┤
    │ 0 │ "2024-10-11/2024-10-16" │
    │ 1 │ 1728604800000 │
    │ 2 │ 1729123199999 │
    │ 3 │ undefined │
    │ 4 │ undefined │
    │ 5 │ true │
    │ 6 │ true │
    └───────┴─────────────────────────┘
  3. mbbx6spp created this gist Oct 14, 2024.
    37 changes: 37 additions & 0 deletions edts.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    import edtf, { Date, Interval } from 'npm:edtf@4.6.0';

    const approxStartDate = edtf('2024-10-14~');
    const uncertainDate = edtf('2024-10-14?');
    const interval = edtf('2024-10-11/2024-10-16');

    console.table([
    approxStartDate.edtf,
    approxStartDate.min,
    approxStartDate.max,
    approxStartDate.approximate,
    approxStartDate.uncertain,
    approxStartDate.covers(approxStartDate),
    approxStartDate.covers(uncertainDate),
    approxStartDate.covers(approxStartDate.next()),
    ])

    console.table([
    uncertainDate.edtf,
    uncertainDate.min,
    uncertainDate.max,
    uncertainDate.approximate,
    uncertainDate.uncertain,
    uncertainDate.covers(uncertainDate),
    uncertainDate.covers(approxStartDate),
    uncertainDate.covers(uncertainDate.next()),
    ])

    console.table([
    interval.edtf,
    interval.min,
    interval.max,
    interval.approximate,
    interval.uncertain,
    interval.covers(uncertainDate),
    interval.covers(approxStartDate),
    ])