Socket
Socket
Sign inDemoInstall

finn-date-formatter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

finn-date-formatter

Date formatter compliant with FINN's styleguide for date formatting: https://styleguide.finn.no/


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Install size
Created

Readme

Source

FINN date formatter

THIS PROJECT IS AN ONGOING EXPERIMENT. No support can be expected.

npm package for formatting Dates, FINN style. From the styleguide (November 6, 2015):

Dates and time

Specified time

In Finn we display time and dates the following way:

  • 11. okt 2015 (without time)
  • 11. okt 2015 23:59 (with time)
Relative time

If it's less than 3 days you can show relative time like this:

  • Et øyeblikk siden
  • 1 minutt siden
  • 59 minutter siden
  • 1 time siden
  • 23 timer siden
  • 1 dag siden
  • 2 dager siden

Installation

Use the npm.finntech.no registry by adding the following to your .npmrc file:

# download all packages from the FINN npm registry
registry=http://npm.finntech.no/

Then install via npm:

npm install --save finn-date-formatter

Usage

The module exports a default function format(date: Date[, options: Object]).

Example
import formatDate from 'finn-date-formatter';

const date = new Date('October 11, 2015 03:23:00');

// 11. okt 2015
format(date);

// 11. okt 2015 03:23
format(date, {
  showTime: true
});

// 11.10.2015 03:23
format(date, {
  monthAsNumber: true,
  showTime: true,
});

// Et øyeblikk siden
const now = new Date();
format(date);

See the unit tests in test/ for further usage.

Available options
  • boolean showTime: Appends time on the format HH:MM
  • boolean monthAsNumber: Displays 11.10.2015 instead of 11. okt 2015

Development

FAQs

Package last updated on 20 Nov 2016

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc