Giter VIP home page Giter VIP logo

ayame113 / temporarily Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 43 KB

This library provides a date string parser for use with the Temporal API. This library currently only supports basic date string formats. If you have any additional date string formats you'd like us to support, please let us know in the GitHub repository!

Home Page: https://jsr.io/@ayame113/temporarily

License: MIT License

Dockerfile 1.21% TypeScript 98.79%
deno jsr temporal

temporarily's Introduction

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.

temporarily's People

Contributors

ayame113 avatar

Stargazers

Rintaro Itokawa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.