1.0.4 • Published 7 months ago

lit-date v1.0.4

Weekly downloads
17
License
MIT
Repository
github
Last release
7 months ago

⏰ lit-date

NPM filesize codecov

Light-weight, faster datetime formatter for modern browsers.

lit-date is ...

  • ⏰ Formatter for Date object
  • 👼 Light-weight (~1kB gzipped!)
  • 🦄 Very faster than other datetime libraries (e.g. moment)
  • 🆕 Powered by Template literals

Install

Node.js

npm i --save lit-date
# -- OR --
yarn add lit-date

Browser

<script src="https://unpkg.com/lit-date"></script>
<script type="module">
  import litdate from 'https://unpkg.com/lit-date?module';
</script>

Usage

const text = litdate`${'YYYY'}/${'MM'}/${'DD'}`(new Date());
console.log(text);
// i18n
const dayOfWeek = ({ dayOfWeek }) => [...'日月火水木金土'][dayOfWeek];
const format = litdate`${'M'}月${'D'}日${dayOfWeek}曜日`;
console.log(format(new Date()));

See examples.

Benchmark

See benchmarks for more details.

Basic usage

  • new Date() -> 2000/01/06
ChromeFirefox
Basic usage / ChromeBasic usage / Firefox

Advanced usage

  • new Date() -> 1月6日(木)
ChromeFirefox
Advanced usage / ChromeAdvanced usage / Firefox

Bundle size

sizegzip
tinydatetinydate_sizetinydate_gzip
time-stamptime-stamp_sizetime-stamp_gzip
lit-datelit-date_sizelit-date_gzip
tinytimetinytime_sizetinytime_gzip
date-formatdate-format_sizedate-format_gzip
dateformatdateformat_sizedateformat_gzip
formatoidformatoid_sizeformatoid_gzip
fechafecha_sizefecha_gzip
dayjsdayjs_sizedayjs_gzip
date-fnsdate-fns_sizedate-fns_gzip
luxonluxon_sizeluxon_gzip
momentmoment_sizemoment_gzip

Contribute

PRs accepted.

License

MIT (c) 3846masa