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');
format(date);
format(date, {
showTime: true
});
format(date, {
monthAsNumber: true,
showTime: true,
});
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