New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dateism

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dateism - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

15

index.js

@@ -7,3 +7,3 @@ const addDays = require('date-fns/add_days')

class Dateism {
constructor(format, seed) {
constructor({format, seed} = {}) {
this.formatPattern = format

@@ -39,11 +39,14 @@ this.seed = seed || new Date()

format (value) {
return formatDate(value, this.formatPattern)
if (this.formatPattern) {
return formatDate(value, this.formatPattern)
}
return value.toISOString()
}
startOfDay () {
return new Dateism(this.formatPattern, startOfDay(this.seed))
return new Dateism({format: this.formatPattern, seed: startOfDay(this.seed)})
}
endOfDay () {
return new Dateism(this.formatPattern, endOfDay(this.seed))
return new Dateism({format: this.formatPattern, seed: endOfDay(this.seed)})
}

@@ -53,5 +56,5 @@ }

module.exports = (format, seed) => {
return new Dateism(format, seed)
module.exports = ({format, seed} = {}) => {
return new Dateism({format, seed})
}

2

package.json
{
"name": "dateism",
"version": "0.0.2",
"version": "0.1.0",
"description": "Yesterday today and tomorrow",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -20,3 +20,3 @@ # dateism [![npm version](https://img.shields.io/npm/v/dateism.svg)](https://www.npmjs.com/package/dateism) [![npm](https://img.shields.io/npm/dm/dateism.svg)](https://www.npmjs.com/package/dateism) [![Build Status](https://travis-ci.org/featurist/dateism.svg?branch=master)](https://travis-ci.org/featurist/dateism)

const dateism = require('dateism')
const dates = dateism('DD MMM YYYY', new Date('1947-02-15'))
const dates = dateism({format: 'DD MMM YYYY', seed: new Date('1947-02-15')})

@@ -23,0 +23,0 @@ dates.addDays(-5) // -> '10 Feb 1947'

@@ -6,7 +6,7 @@ const expect = require('chai').expect

it('returns date in x days in the specified format', () => {
const dates = dateism('YYYY-MM-DD', new Date('2017-05-13'))
const dates = dateism({format: 'YYYY-MM-DD', seed: new Date('2017-05-13')})
expect(dates.addDays(2)).to.eql('2017-05-15')
})
it('returns todays date in the specified format', () => {
const dates = dateism('YYYY-MM-DD', new Date('2017-05-13'))
const dates = dateism({format: 'YYYY-MM-DD', seed: new Date('2017-05-13')})
expect(dates.today()).to.eql('2017-05-13')

@@ -16,3 +16,3 @@ })

it('returns yesterdays date in the specified format', () => {
const dates = dateism('YYYY-MM-DD', new Date('2017-05-13'))
const dates = dateism({format: 'YYYY-MM-DD', seed: new Date('2017-05-13')})
expect(dates.yesterday()).to.eql('2017-05-12')

@@ -22,3 +22,3 @@ })

it('returns the date from two days ago in the specified format', () => {
const dates = dateism('YYYY-MM-DD', new Date('2017-05-13'))
const dates = dateism({format: 'YYYY-MM-DD', seed: new Date('2017-05-13')})
expect(dates.twoDaysAgo()).to.eql('2017-05-11')

@@ -28,3 +28,3 @@ })

it('returns the date from three days ago in the specified format', () => {
const dates = dateism('YYYY-MM-DD', new Date('2017-05-13'))
const dates = dateism({format: 'YYYY-MM-DD', seed: new Date('2017-05-13')})
expect(dates.threeDaysAgo()).to.eql('2017-05-10')

@@ -34,3 +34,3 @@ })

it('returns tomorrows date in the specified format', () => {
const dates = dateism('YYYY-MM-DD', new Date('2017-05-13'))
const dates = dateism({format: 'YYYY-MM-DD', seed: new Date('2017-05-13')})
expect(dates.tomorrow()).to.eql('2017-05-14')

@@ -40,3 +40,3 @@ })

it('returns the days date at the start of the day', () => {
const dates = dateism('YYYY-MM-DDTHH:mm:ss', new Date('2017-05-13T13:56:12'))
const dates = dateism({format: 'YYYY-MM-DDTHH:mm:ss', seed: new Date('2017-05-13T13:56:12')})
expect(dates.startOfDay().today()).to.eql('2017-05-13T00:00:00')

@@ -46,5 +46,10 @@ })

it('returns the days date at the end of the day', () => {
const dates = dateism('YYYY-MM-DDTHH:mm:ss', new Date('2017-05-13T13:56:12'))
const dates = dateism({format: 'YYYY-MM-DDTHH:mm:ss', seed: new Date('2017-05-13T13:56:12')})
expect(dates.endOfDay().today()).to.eql('2017-05-13T23:59:59')
})
it('specifying no format defaults to UTC ISO string', () => {
const dates = dateism({seed: new Date('2017-05-13T13:00:00Z')})
expect(dates.addDays(1)).to.eql('2017-05-14T13:00:00.000Z')
})
})
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