This package has been deprecated

Author message:

We merged all @superset-ui packages. Use @superset-ui/core instead.

@superset-ui/time-format
TypeScript icon, indicating that this package has built-in type declarations

0.14.23 • Public • Published

@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.

Readme

Keywords

Package Sidebar

Install

npm i @superset-ui/time-format

Weekly Downloads

236

Version

0.14.23

License

Apache-2.0

Unpacked Size

82.6 kB

Total Files

67

Last publish

Collaborators

  • eschutho
  • arash_suri
  • michael.s.molina
  • suddjian
  • superset-ui-owner
  • kristw
  • data-ui
  • conglei
  • christopher.card.williams
  • soboko
  • mistercrunch
  • cdchambers
  • khtruong
  • erik_ritter
  • graceguo-supercat
  • michellet
  • supersetbot
  • ktmud
  • villebro
  • rusackas
  • kgabryje