New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

isomorphic-date

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-date

Just dates, no time, no dependencies

latest
Source
npmnpm
Version
0.1.6
Version published
Weekly downloads
7
600%
Maintainers
1
Weekly downloads
 
Created
Source

isomorphic-date

When you only want to work with days and dates. Skipping the hassle of time and timezones.

###Examples:###

var holidays = require('isomorphic-date').holidays.se_sv
var i18n = require('isomorphic-date').i18n.sv

// Create date object with provided translation files and i18n data
var SimpleDate = require('isomorphic-date').createSimpleDate(holidays, i18n)

// Create a date by passing a js date obj
var today = new SimpleDate(new Date())
today.daysFromToday() == 0
today.daysFromTodayAsText() == "Idag" // "Today" in swedish as per i18n data

// Create a date by passing a string
var date = new SimpleDate("2016-01-01")
date.toString() == "2016-01-01"
date.year == 2016
date.month == 1
date.day == 1
date.isoWeekNr() == 1
date.isHoliday() == "Nyårsdagen" // Returns false || true (Sundays) || string (if it is a holiday according to the passed holiday data)

date.deltaDays(1)


// Create a date by passing params
var date = new SimpleDate(2016, 1, 5)
date.toString() == "2016-01-05"

// Create a date by passing another SimpleDate obj
var date2 = new SimpleDate(date)
date2.toString() == "2016-01-05"

// Compare simple dates
date2.eq(date) // true
date.lt(today) // true
date.gt(today) // false

i18n and holidays

To internationalise you can copy and edit lib/holidays/se_sv.js and lib/i18n/sv.js. Pass your customised objects to the SimpleDate factory:

var holidays = require('./custom_holidays.js')
var i18n = require('./custom_i18n.js')

var SimpleDate = require('isomorphic-date')(holidays, i18n)

Tests

To run the tests do an npm install and then npm run test.

FAQs

Package last updated on 20 Dec 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