Skip to main content
Module

x/fresh_charts/deps.ts>ChartJs.DateAdapter

A server-side-rendered charting library for Fresh
Go to Latest
interface ChartJs.DateAdapter
import { type ChartJs } from "https://deno.land/x/fresh_charts@0.2.0/deps.ts";
const { DateAdapter } = ChartJs;

Type Parameters

optional
T extends AnyObject = AnyObject

Properties

readonly
options: T

Methods

init(this: DateAdapter<T>, chartOptions: ChartOptions): void

Will called with chart options after adapter creation.

formats(this: DateAdapter<T>): Record<string, string>

Returns a map of time formats for the supported formatting units defined in Unit as well as 'datetime' representing a detailed date/time string.

parse(
this: DateAdapter<T>,
value: unknown,
format?: TimeUnit,
): number | null

Parses the given value and return the associated timestamp.

format(
this: DateAdapter<T>,
timestamp: number,
format: TimeUnit,
): string

Returns the formatted date in the specified format for a given timestamp.

add(
this: DateAdapter<T>,
timestamp: number,
amount: number,
unit: TimeUnit,
): number

Adds the specified amount of unit to the given timestamp.

diff(
this: DateAdapter<T>,
a: number,
b: number,
unit: TimeUnit,
): number

Returns the number of unit between the given timestamps.

startOf(
this: DateAdapter<T>,
timestamp: number,
unit: TimeUnit | "isoWeek",
weekday?: number,
): number

Returns start of unit for the given timestamp.

endOf(
this: DateAdapter<T>,
timestamp: number,
unit: TimeUnit | "isoWeek",
): number

Returns end of unit for the given timestamp.