year-month-day
Advanced tools
Comparing version 1.0.0 to 2.0.0
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') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71616
8
320
17
4
1