Socket
Socket
Sign inDemoInstall

@financial-times/ft-date-format

Package Overview
Dependencies
0
Maintainers
11
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @financial-times/ft-date-format

Utility for formatting and updating dates for Financial-Times customer-facing products


Version published
Weekly downloads
3.8K
increased by8.84%
Maintainers
11
Install size
42.2 kB
Created
Weekly downloads
 

Readme

Source

ft-date-format

ft-date-format provides javascript utilities for formatting and updating dates in FT style.

  • Usage
  • Migration Guide
  • Contact
  • Licence

Usage

JavaScript

ft-date-format#format(date, tpl)

Returns a date formatted as a string

  • date: A javascript Date object or a valid string to pass to the Date constructor
  • tpl: A string specifying what format to output the date in:
    • 'datetime': formats the date in the standard FT long format, including the time. E.g. May 15, 2014 8:10 am
    • 'date': formats the date in the standard FT long format. E.g. May 15, 2014
    • Any other string using widespread conventions for time/date placeholders, which will be replaced with values extracted from the date provided. See ./main.js for an up to date list of supported formats. To avoid e.g. the mm in common being replaced with the month prefix with a double backslash co\\mmon i.e. In most cases custom date formats should not be used, in favour of the standard FT date and datetime formats
ft-date-format#timeAgo(date)

Returns the relative time since the given date, formatted as a human readable string e.g. 13 minutes ago.

ft-date-format#ftTime(date)

Returns relative time or timestamp for a given date, in accordance with FT date formatting conventions.

  • date: A javascript Date object or a valid string to pass to the Date constructor
ft-date-format#asTodayOrYesterdayOrNothing(date)

Returns 'yesterday', 'today' or '' for a given date. You can request this formatting for ft-date-format components by adding data-ft-date-format-format="today-or-yesterday-or-nothing".

  • date: A javascript Date object or a valid string to pass to the Date constructor

Migration Guide

StateMajor VersionLast Minor ReleaseMigration guide
✨ active2N/Amigrate to v2
⚠ maintained11.0.5-

Contact

If you have any questions, comments, or need help using ft-date-format, please either raise an issue, visit #ft-origami or email Origami Support.


Licence

This software is published by the Financial Times under the MIT licence.

FAQs

Last updated on 14 Mar 2023

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc