Home

Awesome

⏰ lit-date

NPM filesize codecov

Light-weight, faster datetime formatter for modern browsers.

lit-date is ...

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

ChromeFirefox
Basic usage / ChromeBasic usage / Firefox

Advanced usage

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