Files
tom goriunovandGitHub 8c70d3be88 Stats: format dates using UTC time instead of local time by default (#3103)
* Stats: format dates using UTC time instead of local time by default

* hide chart tooltip whenever new data comes in
2025-11-05 11:59:25 -03:00

17 lines
514 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
}
}