How to use d3-time-format - 10 common examples

To help you get started, we’ve selected a few d3-time-format examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / d3-time-format / d3-time-format-tests.ts View on Github external
let localeDef: d3TimeFormat.TimeLocaleDefinition;

let localeObj: d3TimeFormat.TimeLocaleObject;

// ----------------------------------------------------------------------
// Test Formating and Parsing
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
github DefinitelyTyped / DefinitelyTyped / d3-time-format / d3-time-format-tests.ts View on Github external
let localeObj: d3TimeFormat.TimeLocaleObject;

// ----------------------------------------------------------------------
// Test Formating and Parsing
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
github DefinitelyTyped / DefinitelyTyped / types / d3-time-format / d3-time-format-tests.ts View on Github external
let localeObj: d3TimeFormat.TimeLocaleObject;

// ----------------------------------------------------------------------
// Test Formating and Parsing
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
github DefinitelyTyped / DefinitelyTyped / d3-time-format / d3-time-format-tests.ts View on Github external
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months;
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;

localeDef = {
    dateTime: '%a %b %e %X %Y',
github DefinitelyTyped / DefinitelyTyped / types / d3-time-format / d3-time-format-tests.ts View on Github external
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months;
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;

localeDef = {
    dateTime: '%a %b %e %X %Y',
github DefinitelyTyped / DefinitelyTyped / types / d3-time-format / d3-time-format-tests.ts View on Github external
// Test Formating and Parsing
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months;
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;

localeDef = {
github DefinitelyTyped / DefinitelyTyped / d3-time-format / d3-time-format-tests.ts View on Github external
// Test Formating and Parsing
// ----------------------------------------------------------------------

// local time -----------------------------------------------------------

formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');

// utc ------------------------------------------------------------------

formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');

// iso ------------------------------------------------------------------

let dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
let date: Date = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');

// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------

let dateTimeSpecifier: string = localeDef.dateTime;
let dateSpecifier: string = localeDef.date;
let timeSpecifier: string = localeDef.time;
let periods: [string, string] = localeDef.periods;
let days: [string, string, string, string, string, string, string] = localeDef.days;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months;
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;

localeDef = {
github Jacwutang / CryptoEngineX / client / src / components / Chart / utils.js View on Github external
import { tsvParse, csvParse } from 'd3-dsv';
import { timeParse } from 'd3-time-format';
import axios from 'axios';
import ccxt from 'ccxt';

// const parseDateTime = timeParse('%Y-%m-%dT%H:%M:%S.%LZ');
const parseDateTime = timeParse('%Q');

// function parseData(ticker) {
//   let d = {};
//   d.date = parseDateTime(ticker.datetime);
//   d.close = ticker.close;
//   d.high = ticker.high;
//   d.low = ticker.low;
//   d.volume = parseFloat(ticker.info.volume);
//
//   return d;
// }

const timeframeToMSHash = {
  '1m': 1000 * 60,
  '1h': 1000 * 60 * 60,
  '1M': 2629742 * 1000,
github hshoff / vx / packages / vx-demo / src / components / tiles / threshold.js View on Github external
import React from 'react';
import { Group } from '@vx/group';
import { curveBasis } from '@vx/curve';
import { LinePath } from '@vx/shape';
import { Threshold } from '@vx/threshold';
import { scaleTime, scaleLinear } from '@vx/scale';
import { AxisLeft, AxisBottom } from '@vx/axis';
import { GridRows, GridColumns } from '@vx/grid';
import { cityTemperature as data } from '@vx/mock-data';
import { timeParse } from 'd3-time-format';

const parseDate = timeParse('%Y%m%d');

// accessors
const date = d => parseDate(d.date);
const ny = d => d['New York'];
const sf = d => d['San Francisco'];

// scales
const xScale = scaleTime({
  domain: [Math.min(...data.map(date)), Math.max(...data.map(date))],
});
const yScale = scaleLinear({
  domain: [
    Math.min(...data.map(d => Math.min(ny(d), sf(d)))),
    Math.max(...data.map(d => Math.max(ny(d), sf(d)))),
  ],
  nice: true,
github rrag / react-stockcharts / docs / documentation.js View on Github external
import React from "react";
import ReactDOM from "react-dom";

import { csvParse, tsvParse } from  "d3-dsv";
import { merge } from "d3-array";
import { timeParse } from "d3-time-format";

const parseDate = timeParse("%Y-%m-%d");
const parseDateTime = timeParse("%Y-%m-%d %H:%M:%S");


import { TypeChooser } from "react-stockcharts/lib/helper";
import "stylesheets/re-stock";

import Nav from "lib/navbar";
import Sidebar from "lib/sidebar";
import MainContainer from "lib/main-container";
import MenuGroup from "lib/menu-group";
import MenuItem from "lib/MenuItem";

const DOCUMENTATION = {
	head: "Documentation",
	pages: [
		// require("./lib/page/GettingStartedPage").default,