Skip to main content
Home

Built and signed on GitHub Actions

This library provides a date string parser for use with the Temporal API.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.0.5)

temporarily

Datetime parser for Temporal API.

// main.ts
import { parse } from "./mod.ts";

const parsed = parse("2024-05-03 15:25:29", "%Y-%m-%d %H:%M:%S");
console.log(parsed); // { year: 2024, month: 5, day: 3, hour: 15, minute: 25, second: 29 }

const date = Temporal.PlainDateTime.from(parsed);
console.log(date); // Temporal { 2024-05-03T15:25:29 }
deno run --unstable-temporal ./main.ts

supported formats

  • %Y: year (e.g. 2024)
  • %m: month, zero-padded to 2 digits (e.g. 05)
  • %-m: month (e.g. 5)
  • %d: day, zero-padded to 2 digits (e.g. 03)
  • %-d: day (e.g. 3)
  • %H: hour, zero-padded to 2 digits (e.g. 09)
  • %-H: hour (e.g. 9)
  • %I: hour in 12-hour clocks, zero-padded to 2 digits (e.g. 03)
  • -%I: hour in 12-hour clocks (e.g. 3)
  • %p: AM/PM (e.g. PM)
  • %P: am/pm (e.g. pm)
  • %M: minute, zero-padded to 2 digits (e.g. 25)
  • %-M: minute (e.g. 25)
  • %S: second, zero-padded to 2 digits (e.g. 29)
  • %-S: second (e.g. 29)
  • %%: %

This library's format strings are based on the Rust library chrono. Some other formats included in chrono are also supported.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@ayame113/temporarily

Import symbol

import * as temporarily from "@ayame113/temporarily";
or

Import directly with a jsr specifier

import * as temporarily from "jsr:@ayame113/temporarily";

Add Package

pnpm i jsr:@ayame113/temporarily
or (using pnpm 10.8 or older)
pnpm dlx jsr add @ayame113/temporarily

Import symbol

import * as temporarily from "@ayame113/temporarily";

Add Package

yarn add jsr:@ayame113/temporarily
or (using Yarn 4.8 or older)
yarn dlx jsr add @ayame113/temporarily

Import symbol

import * as temporarily from "@ayame113/temporarily";

Add Package

vlt install jsr:@ayame113/temporarily

Import symbol

import * as temporarily from "@ayame113/temporarily";

Add Package

npx jsr add @ayame113/temporarily

Import symbol

import * as temporarily from "@ayame113/temporarily";

Add Package

bunx jsr add @ayame113/temporarily

Import symbol

import * as temporarily from "@ayame113/temporarily";