mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* Stats: format dates using UTC time instead of local time by default * hide chart tooltip whenever new data comes in
17 lines
514 B
TypeScript
17 lines
514 B
TypeScript
import * as d3 from 'd3';
|
||
|
||
import { Resolution } from '../types';
|
||
|
||
export function getDateLabel(date: Date, dateTo?: Date, resolution?: Resolution): string {
|
||
switch (resolution) {
|
||
case Resolution.WEEK:
|
||
return d3.utcFormat('%e %b %Y')(date) + (dateTo ? ` – ${ d3.utcFormat('%e %b %Y')(dateTo) }` : '');
|
||
case Resolution.MONTH:
|
||
return d3.utcFormat('%b %Y')(date);
|
||
case Resolution.YEAR:
|
||
return d3.utcFormat('%Y')(date);
|
||
default:
|
||
return d3.utcFormat('%e %b %Y')(date);
|
||
}
|
||
}
|