@types/d3-time

  • Version 3.0.3
  • Published
  • 30.7 kB
  • No dependencies
  • MIT license

Install

npm i @types/d3-time
yarn add @types/d3-time
pnpm add @types/d3-time

Overview

TypeScript definitions for d3-time

Index

Variables

variable timeDay

const timeDay: CountableTimeInterval;
  • Days Interval in Local Time; days (e.g., February 7, 2012 at 12:00 AM); typically 24 hours. Days in local time may range from 23 to 25 hours due to daylight saving.

variable timeFriday

const timeFriday: CountableTimeInterval;
  • Week Interval for Friday-based weeks in Local Time (e.g., February 10, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeHour

const timeHour: CountableTimeInterval;
  • Hours Interval in Local Time; Hours (e.g., 01:00 AM); 60 minutes.

    Note that advancing time by one hour in local time can return the same hour or skip an hour due to daylight saving.

variable timeMillisecond

const timeMillisecond: CountableTimeInterval;
  • Milliseconds Interval in Local Time; the shortest available time unit.

variable timeMinute

const timeMinute: CountableTimeInterval;
  • Minutes Interval in Local Time; minutes (e.g., 01:02:00 AM); 60 seconds. Note that ECMAScript ignores leap seconds.

variable timeMonday

const timeMonday: CountableTimeInterval;
  • Week Interval for Monday-based weeks in Local Time (e.g., February 6, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeMonth

const timeMonth: CountableTimeInterval;
  • Month Interval in Local Time; months (e.g., February 1, 2012 at 12:00 AM); ranges from 28 to 31 days.

variable timeSaturday

const timeSaturday: CountableTimeInterval;
  • Week Interval for Saturday-based weeks in Local Time (e.g., February 11, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeSecond

const timeSecond: CountableTimeInterval;
  • Seconds Interval in Local Time; seconds (e.g., 01:23:45.0000 AM); 1,000 milliseconds.

variable timeSunday

const timeSunday: CountableTimeInterval;
  • Week Interval for Sunday-based weeks in Local Time (e.g., February 5, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeThursday

const timeThursday: CountableTimeInterval;
  • Week Interval for Thursday-based weeks in Local Time (e.g., February 9, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeTuesday

const timeTuesday: CountableTimeInterval;
  • Week Interval for Tuesday-based weeks in Local Time (e.g., February 7, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeWednesday

const timeWednesday: CountableTimeInterval;
  • Week Interval for Wednesday-based weeks in Local Time (e.g., February 8, 2012 at 12:00 AM). 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeWeek

const timeWeek: CountableTimeInterval;
  • Week Interval in Local Time. Alias for sunday; 7 days and typically 168 hours.

    Weeks in local time may range from 167 to 169 hours due on daylight saving.

variable timeYear

const timeYear: CountableTimeInterval;
  • Year Interval in Local Time; years (e.g., January 1, 2012 at 12:00 AM); ranges from 365 to 366 days.

variable utcDay

const utcDay: CountableTimeInterval;
  • Days Interval in Coordinated Universal Time (UTC); days (e.g., February 7, 2012 at 12:00 AM); 24 hours.

variable utcFriday

const utcFriday: CountableTimeInterval;
  • Week Interval for Friday-based weeks in Coordinated Universal Time (UTC) (e.g., February 10, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcHour

const utcHour: CountableTimeInterval;
  • Hours Interval in Coordinated Universal Time (UTC); Hours (e.g., 01:00 AM); 60 minutes.

variable utcMillisecond

const utcMillisecond: CountableTimeInterval;
  • Milliseconds Interval in Coordinated Universal Time (UTC); the shortest available time unit.

variable utcMinute

const utcMinute: CountableTimeInterval;
  • Minutes Interval in Coordinated Universal Time (UTC); minutes (e.g., 01:02:00 AM); 60 seconds. Note that ECMAScript ignores leap seconds.

variable utcMonday

const utcMonday: CountableTimeInterval;
  • Week Interval for Monday-based weeks in Coordinated Universal Time (UTC) (e.g., February 6, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcMonth

const utcMonth: CountableTimeInterval;
  • Month Interval in Coordinated Universal Time (UTC); months (e.g., February 1, 2012 at 12:00 AM); ranges from 28 to 31 days.

variable utcSaturday

const utcSaturday: CountableTimeInterval;
  • Week Interval for Saturday-based weeks in Coordinated Universal Time (UTC) (e.g., February 11, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcSecond

const utcSecond: CountableTimeInterval;
  • Seconds Interval in Coordinated Universal Time (UTC); seconds (e.g., 01:23:45.0000 AM); 1,000 milliseconds.

variable utcSunday

const utcSunday: CountableTimeInterval;
  • Week Interval for Sunday-based weeks in Coordinated Universal Time (UTC) (e.g., February 5, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcThursday

const utcThursday: CountableTimeInterval;
  • Week Interval for Thursday-based weeks in Coordinated Universal Time (UTC) (e.g., February 9, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcTuesday

const utcTuesday: CountableTimeInterval;
  • Week Interval for Tuesday-based weeks in Coordinated Universal Time (UTC) (e.g., February 7, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcWednesday

const utcWednesday: CountableTimeInterval;
  • Week Interval for Wednesday-based weeks in Coordinated Universal Time (UTC) (e.g., February 8, 2012 at 12:00 AM). 7 days and 168 hours.

variable utcWeek

const utcWeek: CountableTimeInterval;
  • Week Interval in Local Time. Alias for sunday; 7 days and 168 hours.

variable utcYear

const utcYear: CountableTimeInterval;
  • Year Interval in Coordinated Universal Time (UTC); years (e.g., January 1, 2012 at 12:00 AM); ranges from 365 to 366 days.

Functions

function timeDays

timeDays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeDay.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeFridays

timeFridays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeFriday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeHours

timeHours: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeHour.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeInterval

timeInterval: {
(
floor: (date: Date) => void,
offset: (date: Date, step: number) => void
): TimeInterval;
(
floor: (date: Date) => void,
offset: (date: Date, step: number) => void,
count: (start: Date, end: Date) => number,
field?: (date: Date) => number
): CountableTimeInterval;
};
  • Constructs a new custom interval given the specified floor and offset functions.

    The returned custom interval is not countable, i.e. does not expose the methods "count(..)" and "every(...)".

    Parameter floor

    A floor function which takes a single date as an argument and rounds it down to the nearest interval boundary.

    Parameter offset

    An offset function which takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero.

  • Constructs a new custom interval given the specified floor, offset and count functions.

    The returned custom interval is countable and exposes the methods "count(..)" and "every(...)".

    Note: due to an internal optimization, the specified count function must not invoke interval.count on other time intervals.

    Parameter floor

    A floor function which takes a single date as an argument and rounds it down to the nearest interval boundary.

    Parameter offset

    An offset function which takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero.

    Parameter count

    A count function which takes a start date and an end date, already floored to the current interval, and returns the number of boundaries between the start (exclusive) and end (inclusive). Note: due to an internal optimization, the specified count function must not invoke interval.count on other time intervals.

    Parameter field

    An optional field function which takes a date, already floored to the current interval, and returns the field value of the specified date, corresponding to the number of boundaries between this date (exclusive) and the latest previous parent boundary. For example, for the timeDay interval, this returns the number of days since the start of the month. If a field function is not specified, it defaults to counting the number of interval boundaries since the UNIX epoch of January 1, 1970 UTC. The field function defines the behavior of interval.every.

function timeMilliseconds

timeMilliseconds: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeMillisecond.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeMinutes

timeMinutes: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeMinute.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeMondays

timeMondays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeMonday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeMonths

timeMonths: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeMonth.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeSaturdays

timeSaturdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeSaturday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeSeconds

timeSeconds: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeSecond.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeSundays

timeSundays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeSunday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeThursdays

timeThursdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeThursday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeTickInterval

timeTickInterval: (
start: Date,
stop: Date,
count: number
) => TimeInterval | null;
  • Returns the time interval that would be used by d3.timeTicks given the same arguments.

function timeTicks

timeTicks: (start: Date, stop: Date, count: number) => Date[];
  • Equivalent to d3.utcTicks, but in local time.

function timeTuesdays

timeTuesdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeTuesday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeWednesdays

timeWednesdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeWednesday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeWeeks

timeWeeks: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeWeek.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function timeYears

timeYears: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for timeYear.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcDays

utcDays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcDay.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcFridays

utcFridays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcFriday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcHours

utcHours: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcHour.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcMilliseconds

utcMilliseconds: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcMillisecond.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcMinutes

utcMinutes: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcMinute.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcMondays

utcMondays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcMonday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcMonths

utcMonths: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcMonth.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcSaturdays

utcSaturdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcSaturday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcSeconds

utcSeconds: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcSecond.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcSundays

utcSundays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcSunday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcThursdays

utcThursdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcThursday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcTickInterval

utcTickInterval: (start: Date, stop: Date, count: number) => TimeInterval | null;
  • Returns the time interval that would be used by d3.utcTicks given the same arguments. If there is no associated interval, such as when start or stop is invalid, returns null.

function utcTicks

utcTicks: (start: Date, stop: Date, count: number) => Date[];
  • Returns an array of approximately count dates at regular intervals between start and stop (inclusive). If stop is before start, dates are returned in reverse chronological order; otherwise dates are returned in chronological order.

function utcTuesdays

utcTuesdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcTuesday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcWednesdays

utcWednesdays: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcWednesday.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcWeeks

utcWeeks: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcWeek.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

function utcYears

utcYears: (start: Date, stop: Date, step?: number) => Date[];
  • This is a convenience alias for utcYear.range(...).

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

Interfaces

interface CountableTimeInterval

interface CountableTimeInterval extends TimeInterval {}
  • A D3 Countable Time Interval

method count

count: (start: Date, end: Date) => number;
  • Returns the number of interval boundaries after start (exclusive) and before or equal to end (inclusive).

    Note that this behavior is slightly different than interval.range, because its purpose is to return the zero-based number of the specified end date relative to the specified start date.

    Parameter start

    A start date object.

    Parameter end

    An end date object.

method every

every: (step: number) => TimeInterval | null;
  • Returns a filtered view of this interval representing every stepth date.

    The meaning of step is dependent on this interval’s parent interval as defined by the field function.

    For example, timeMinute.every(15) returns an interval representing every fifteen minutes, starting on the hour: :00, :15, :30, :45, etc. Note that for some intervals, the resulting dates may not be uniformly-spaced; timeDay’s parent interval is timeMonth, and thus the interval number resets at the start of each month.

    If step is not valid, returns null. If step is one, returns this interval.

    This method can be used in conjunction with interval.range to ensure that two overlapping ranges are consistent.

    The returned filtered interval does not support interval.count. See also interval.filter.

    Parameter step

    Number of steps.

interface TimeInterval

interface TimeInterval {}
  • A D3 Time Interval

method ceil

ceil: (date: Date) => Date;
  • Returns a new date representing the earliest interval boundary date after or equal to date.

    For example, timeDay.ceil(date) typically returns 12:00 AM local time on the date following the given date.

    This method is idempotent: if the specified date is already ceilinged to the current interval, a new date with an identical time is returned. Furthermore, the returned date is the maximum expressible value of the associated interval, such that interval.ceil(interval.ceil(date) + 1) returns the following interval boundary date.

    Parameter date

    A date object.

method filter

filter: (test: (date: Date) => boolean) => TimeInterval;
  • Returns a new interval that is a filtered subset of this interval using the specified test function.

    Parameter test

    A test function which is passed a date and should return true if and only if the specified date should be considered part of the interval.

method floor

floor: (date: Date) => Date;
  • Returns a new date representing the latest interval boundary date before or equal to date.

    For example, timeDay.floor(date) typically returns 12:00 AM local time on the given date.

    This method is idempotent: if the specified date is already floored to the current interval, a new date with an identical time is returned. Furthermore, the returned date is the minimum expressible value of the associated interval, such that interval.floor(interval.floor(date) - 1) returns the preceding interval boundary date.

    Note that the == and === operators do not compare by value with Date objects, and thus you cannot use them to tell whether the specified date has already been floored. Instead, coerce to a number and then compare.

    This is more reliable than testing whether the time is 12:00 AM, as in some time zones midnight may not exist due to daylight saving.

    Parameter date

    A date object.

method offset

offset: (date: Date, step?: number) => Date;
  • Returns a new date equal to date plus step intervals.

    If step is not specified it defaults to 1.

    This method does not round the specified date to the interval. For example, if date is today at 5:34 PM, then timeDay.offset(date, 1) returns 5:34 PM tomorrow (even if daylight saving changes!).

    Parameter date

    A date object.

    Parameter step

    An optional number of steps to apply when calculating the offset date. If step is negative, then the returned date will be before the specified date; if step is zero, then a copy of the specified date is returned; if step is not an integer, it is floored.

method range

range: (start: Date, stop: Date, step?: number) => Date[];
  • Returns an array of dates representing every interval boundary after or equal to start (inclusive) and before stop (exclusive).

    If step is specified, then every step-th boundary will be returned; for example, for the timeDay interval a step of 2 will return every other day. If step is not an integer, it is floored.

    The first date in the returned array is the earliest boundary after or equal to start; subsequent dates are offset by step intervals and floored. Thus, two overlapping ranges may be inconsistent.

    To make ranges consistent when a step is specified, use CountableInterval.every instead.

    Parameter start

    A start date object for the range.

    Parameter stop

    A stop date object for the range.

    Parameter step

    An optional number of steps to apply when calculating the dates in the range.

method round

round: (date: Date) => Date;
  • Returns a new date representing the closest interval boundary date to date.

    For example, timeDay.round(date) typically returns 12:00 AM local time on the given date if it is on or before noon, and 12:00 AM of the following day if it is after noon.

    This method is idempotent: if the specified date is already rounded to the current interval, a new date with an identical time is returned.

    Parameter date

    A date object.

call signature

(date?: Date): Date;
  • Returns a new date representing the latest interval boundary date before or equal to date. Equivalent to interval.floor, except it date is not specified, it defaults to the current time. For example, d3.timeYear(date) and d3.timeYear.floor(date) are equivalent.

    For example, timeDay(date) typically returns 12:00 AM local time on the given date.

    This function is idempotent: if the specified date is already floored to the current interval, a new date with an identical time is returned. Furthermore, the returned date is the minimum expressible value of the associated interval, such that interval.floor(interval.floor(date) - 1) returns the preceding interval boundary date.

    Note that the == and === operators do not compare by value with Date objects, and thus you cannot use them to tell whether the specified date has already been floored. Instead, coerce to a number and then compare.

    This is more reliable than testing whether the time is 12:00 AM, as in some time zones midnight may not exist due to daylight saving.

    Parameter date

    A date object.

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (0)

No dev dependencies.

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/d3-time.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/d3-time)
  • HTML
    <a href="https://www.jsdocs.io/package/@types/d3-time"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>