Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/d3-time-format

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/d3-time-format

TypeScript definitions for d3JS d3-time-format module

  • 3.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6M
increased by4.05%
Maintainers
1
Weekly downloads
 
Created

What is @types/d3-time-format?

@types/d3-time-format provides TypeScript type definitions for the d3-time-format library, which is part of the D3.js suite of modules. This library is used for parsing and formatting dates and times in JavaScript, making it easier to handle date and time data in a consistent and locale-aware manner.

What are @types/d3-time-format's main functionalities?

Formatting Dates

This feature allows you to format dates into human-readable strings using a specified format string. The format string can include various placeholders for different parts of the date.

const d3 = require('d3-time-format');
const formatTime = d3.timeFormat('%B %d, %Y');
console.log(formatTime(new Date())); // Outputs: 'October 05, 2023'

Parsing Dates

This feature allows you to parse date strings into JavaScript Date objects using a specified format string. This is useful for converting string representations of dates into Date objects for further manipulation.

const d3 = require('d3-time-format');
const parseTime = d3.timeParse('%Y-%m-%d');
console.log(parseTime('2023-10-05')); // Outputs: Thu Oct 05 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Locale-Specific Formatting

This feature allows you to create locale-specific date and time formats. You can define custom formats for dates, times, periods, days, and months, which can be used to format dates in a way that is specific to a particular locale.

const d3 = require('d3-time-format');
const locale = d3.timeFormatLocale({
  dateTime: '%x, %X',
  date: '%-m/%-d/%Y',
  time: '%-I:%M:%S %p',
  periods: ['AM', 'PM'],
  days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
});
const formatTime = locale.format('%A, %B %d, %Y');
console.log(formatTime(new Date())); // Outputs: 'Thursday, October 05, 2023'

Other packages similar to @types/d3-time-format

FAQs

Package last updated on 22 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc