Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

year-month-day

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

year-month-day - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

.eslintrc.json

36

index.js

@@ -1,11 +0,27 @@

'use strict';
var daylight = require('daylight');
const daylight = require('daylight')
module.exports = function ymd (d) {
var date = daylight('n j Y', d).split(' ');
return {
year: Number(date[2]),
month: Number(date[0]),
day: Number(date[1])
};
};
/**
@typedef YearMonthDay
@type {object}
@property {number} year - The year.
@property {number} month - The month.
@property {number} day - The day.
*/
/**
* Year-Month-Day
* Take a date object and returns the {YearMonthDay}
* @param {Date} d - Date to return the year, month, and day
* @returns @type {YearMonthDay}
*/
const yearMonthDay = d => {
const date = daylight('n j Y', d).split(' ')
return {
year: Number(date[2]),
month: Number(date[0]),
day: Number(date[1]),
}
}
module.exports = yearMonthDay
{
"name": "year-month-day",
"version": "1.0.0",
"version": "2.0.0",
"description": "",

@@ -9,2 +9,5 @@ "main": "index.js",

},
"engines": {
"node": ">= 8"
},
"repository": {

@@ -20,4 +23,7 @@ "type": "git",

"devDependencies": {
"tap": "^1.3.1"
"@kev_nz/eslint-config": "^3.2.0",
"@kev_nz/publisher": "^1.0.1",
"eslint": "^5.14.1",
"tap": "^12.5.3"
}
}

@@ -1,3 +0,17 @@

# YMD
# Year-Month-Day
Simple function that returns an object with props of year, month and day
Simple function that returns an object with props of year, month and day
## Usage
```js
const ymd = require('year-month-day')
const day = new Date('01/01/2015')
const result = ymd(day)
console.log(result)
// {
// year: 2015,
// month: 1,
// day: 1
// }
```

@@ -1,22 +0,18 @@

'use strict';
const tap = require('tap')
var tap = require('tap');
const ymd = require('../index')
var ymd = require('../index');
const dateToTest = new Date('01/01/2015')
const secondDateToTest = new Date('02/01/2015')
const result = ymd(dateToTest)
var dateToTest = new Date('01/01/2015');
var secondDateToTest = new Date('02/01/2015');
console.log(dateToTest);
var result = ymd(dateToTest);
console.log(result);
tap.equal(result.year, 2015, 'check if year is 2015');
tap.equal(result.month, 1, 'check if month is 1st');
tap.equal(result.day, 1, 'check if day is 1st');
var secondResult = ymd(secondDateToTest);
console.log(secondResult);
tap.equal(result.year, 2015, 'check if year is 2015')
tap.equal(result.month, 1, 'check if month is 1st')
tap.equal(result.day, 1, 'check if day is 1st')
const secondResult = ymd(secondDateToTest)
tap.equal(secondResult.year, 2015, 'check if year is 2015');
tap.equal(secondResult.month, 2, 'check if month is 1st');
tap.equal(secondResult.day, 1, 'check if day is 1st');
tap.equal(secondResult.year, 2015, 'check if year is 2015')
tap.equal(secondResult.month, 2, 'check if month is 1st')
tap.equal(secondResult.day, 1, 'check if day is 1st')
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