0.14.23 • Published 5 years ago

@superset-ui/time-format v0.14.23

Weekly downloads
796
License
Apache-2.0
Repository
github
Last release
5 years ago

@superset-ui/time-format

Version David (path)

Description

Example usage

Add @superset-ui/time-format, a module for formatting time. Functions getTimeFormatter and formatTime should be used instead of calling d3.utcFormat or d3.timeFormat directly.

import { getTimeFormatter } from '@superset-ui/time-format';
const formatter = getTimeFormatter('%Y-%m-d');
console.log(formatter(new Date()));

or

import { formatTime } from '@superset-ui/time-format';
console.log(formatTime('%Y-%m-d', new Date()));

It is powered by a registry to support registration of custom formatting, with fallback to d3.utcFormat or d3.timeFormat (if the formatId starts with local!)

import { getTimeFormatterRegistry, formatTime, TimeFormatter } from '@superset-ui/time-format';

getTimeFormatterRegistry().registerValue('my_format', new TimeFormatter({
  id: 'my_format',
  formatFunc: v => `my special format of ${utcFormat('%Y')(v)}`
});

console.log(formatTime('my_format', new Date(2018)));
// prints 'my special format of 2018'

It also define constants for common d3 time formats. See TimeFormats.js.

import { TimeFormats } from '@superset-ui/time-format';

TimeFormats.DATABASE_DATETIME // '%Y-%m-%d %H:%M:%S'
TimeFormats.US_DATE // '%m/%d/%Y'

API

fn(args)

  • Do something

Development

@data-ui/build-config is used to manage the build configuration for this package including babel builds, jest testing, eslint, and prettier.

0.14.23

5 years ago

0.14.9

5 years ago

0.14.1

5 years ago

0.14.0

5 years ago

0.13.27

5 years ago

0.13.22

5 years ago

0.13.21

5 years ago

0.13.16

5 years ago

0.13.15

5 years ago

0.13.14

5 years ago

0.13.3

5 years ago

0.13.1

5 years ago

0.13.0

5 years ago

0.12.21

5 years ago

0.12.19

5 years ago

0.12.14

5 years ago

0.12.15

5 years ago

0.12.13

5 years ago

0.12.12

5 years ago

0.12.10

5 years ago

0.12.9

5 years ago

0.12.8

5 years ago

0.12.5

6 years ago

0.12.4

6 years ago

0.12.1

6 years ago

0.12.0

6 years ago

0.11.14

6 years ago

0.11.5

6 years ago

0.11.3

6 years ago

0.11.2

6 years ago

0.11.0

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.5

6 years ago

0.9.3

6 years ago

0.9.0

6 years ago

0.8.0

6 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago