@valjoux/convert
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -7,3 +7,3 @@ 'use strict'; | ||
const pa = (n, l) => { | ||
const padDigits = (n, l) => { | ||
n = '' + n; | ||
@@ -16,15 +16,18 @@ | ||
const joinYMD = (y, m, d, l = '-') => ((y = +y) < 1000 ? pa(y, 4) : y) + l + ((m = +m) < 10 ? pa(m, 2) : m) + l + ((d = +d) < 10 ? pa(d, 2) : d); | ||
const padD4 = n => (n = +n) < 1000 ? padDigits(n, 4) : n; | ||
const padD2 = n => ((n = +n) < 10 ? '0' : '') + n; | ||
const dashToDate = dst => new Date(+dst.slice(0, 4), +dst.slice(5, 7) - 1, +dst.slice(8, 10)); | ||
const dashify = (y, m, d, de = '-') => padD4(y) + de + padD2(m) + de + padD2(d); | ||
const dashToDate = dash => new Date(+dash.slice(0, 4), +dash.slice(5, 7) - 1, +dash.slice(8, 10)); | ||
const intToDate = int => new Date(utilBitwise.readYear(int), utilBitwise.readMonth(int) - 1, utilBitwise.readDay(int)); | ||
const ymdToDate = ymd => new Date(ymd[0], ymd[1] - 1, ymd[2]); | ||
const dateToDash = (date, de = '-') => joinYMD(date.getFullYear(), date.getMonth() + 1, date.getDate(), de); | ||
const intToDash = (int, de = '-') => joinYMD(utilBitwise.readYear(int), utilBitwise.readMonth(int), utilBitwise.readDay(int), de); | ||
const ymdToDash = (ymd, de = '-') => joinYMD(ymd[0], ymd[1], ymd[2], de); | ||
const dateToDash = (date, de = '-') => dashify(date.getFullYear(), date.getMonth() + 1, date.getDate(), de); | ||
const intToDash = (int, de = '-') => dashify(utilBitwise.readYear(int), utilBitwise.readMonth(int), utilBitwise.readDay(int), de); | ||
const ymdToDash = (ymd, de = '-') => dashify(ymd[0], ymd[1], ymd[2], de); | ||
const dateToInt = date => utilBitwise.bitYear(date.getFullYear()) + utilBitwise.bitMonth(date.getMonth() + 1) + utilBitwise.bitDay(date.getDate()); | ||
const dashToInt = dst => utilBitwise.bitYear(+dst.slice(0, 4)) + utilBitwise.bitMonth(+dst.slice(5, 7)) + utilBitwise.bitDay(+dst.slice(8, 10)); | ||
const dashToInt = dash => utilBitwise.bitYear(+dash.slice(0, 4)) + utilBitwise.bitMonth(+dash.slice(5, 7)) + utilBitwise.bitDay(+dash.slice(8, 10)); | ||
const ymdToInt = ymd => utilBitwise.bitYear(ymd[0]) + utilBitwise.bitMonth(ymd[1]) + utilBitwise.bitDay(ymd[2]); | ||
const dateToYmd = date => [date.getFullYear(), date.getMonth() + 1, date.getDate()]; | ||
const dashToYmd = dst => [+dst.slice(0, 4), +dst.slice(5, 7), +dst.slice(8, 10)]; | ||
const dashToYmd = dash => [+dash.slice(0, 4), +dash.slice(5, 7), +dash.slice(8, 10)]; | ||
const intToYmd = int => [utilBitwise.readYear(int), utilBitwise.readMonth(int), utilBitwise.readDay(int)]; | ||
@@ -35,2 +38,3 @@ | ||
exports.dashToYmd = dashToYmd; | ||
exports.dashify = dashify; | ||
exports.dateToDash = dateToDash; | ||
@@ -37,0 +41,0 @@ exports.dateToInt = dateToInt; |
import { readYear, readMonth, readDay, bitYear, bitMonth, bitDay } from '@valjoux/util-bitwise'; | ||
const pa = (n, l) => { | ||
const padDigits = (n, l) => { | ||
n = '' + n; | ||
@@ -11,17 +11,20 @@ | ||
const joinYMD = (y, m, d, l = '-') => ((y = +y) < 1000 ? pa(y, 4) : y) + l + ((m = +m) < 10 ? pa(m, 2) : m) + l + ((d = +d) < 10 ? pa(d, 2) : d); | ||
const padD4 = n => (n = +n) < 1000 ? padDigits(n, 4) : n; | ||
const padD2 = n => ((n = +n) < 10 ? '0' : '') + n; | ||
const dashToDate = dst => new Date(+dst.slice(0, 4), +dst.slice(5, 7) - 1, +dst.slice(8, 10)); | ||
const dashify = (y, m, d, de = '-') => padD4(y) + de + padD2(m) + de + padD2(d); | ||
const dashToDate = dash => new Date(+dash.slice(0, 4), +dash.slice(5, 7) - 1, +dash.slice(8, 10)); | ||
const intToDate = int => new Date(readYear(int), readMonth(int) - 1, readDay(int)); | ||
const ymdToDate = ymd => new Date(ymd[0], ymd[1] - 1, ymd[2]); | ||
const dateToDash = (date, de = '-') => joinYMD(date.getFullYear(), date.getMonth() + 1, date.getDate(), de); | ||
const intToDash = (int, de = '-') => joinYMD(readYear(int), readMonth(int), readDay(int), de); | ||
const ymdToDash = (ymd, de = '-') => joinYMD(ymd[0], ymd[1], ymd[2], de); | ||
const dateToDash = (date, de = '-') => dashify(date.getFullYear(), date.getMonth() + 1, date.getDate(), de); | ||
const intToDash = (int, de = '-') => dashify(readYear(int), readMonth(int), readDay(int), de); | ||
const ymdToDash = (ymd, de = '-') => dashify(ymd[0], ymd[1], ymd[2], de); | ||
const dateToInt = date => bitYear(date.getFullYear()) + bitMonth(date.getMonth() + 1) + bitDay(date.getDate()); | ||
const dashToInt = dst => bitYear(+dst.slice(0, 4)) + bitMonth(+dst.slice(5, 7)) + bitDay(+dst.slice(8, 10)); | ||
const dashToInt = dash => bitYear(+dash.slice(0, 4)) + bitMonth(+dash.slice(5, 7)) + bitDay(+dash.slice(8, 10)); | ||
const ymdToInt = ymd => bitYear(ymd[0]) + bitMonth(ymd[1]) + bitDay(ymd[2]); | ||
const dateToYmd = date => [date.getFullYear(), date.getMonth() + 1, date.getDate()]; | ||
const dashToYmd = dst => [+dst.slice(0, 4), +dst.slice(5, 7), +dst.slice(8, 10)]; | ||
const dashToYmd = dash => [+dash.slice(0, 4), +dash.slice(5, 7), +dash.slice(8, 10)]; | ||
const intToYmd = int => [readYear(int), readMonth(int), readDay(int)]; | ||
export { dashToDate, dashToInt, dashToYmd, dateToDash, dateToInt, dateToYmd, intToDash, intToDate, intToYmd, ymdToDash, ymdToDate, ymdToInt }; | ||
export { dashToDate, dashToInt, dashToYmd, dashify, dateToDash, dateToInt, dateToYmd, intToDash, intToDate, intToYmd, ymdToDash, ymdToDate, ymdToInt }; |
{ | ||
"name": "@valjoux/convert", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "date & time util toolset", | ||
@@ -15,6 +15,6 @@ "main": "dist/index.cjs.js", | ||
"pub": "npm publish", | ||
"test": "node -r @babel/register test/test.index.js" | ||
"test": "" | ||
}, | ||
"dependencies": { | ||
"@valjoux/util-bitwise": "^0.0.6" | ||
"@valjoux/util-bitwise": "^0.1.0" | ||
}, | ||
@@ -37,3 +37,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/valjoux#readme", | ||
"gitHead": "9bb74f908875cf3466e6c481d5b1e7038db1f387" | ||
"gitHead": "3fda467a83ee3b780a7eed564707ebc44170fa1e" | ||
} |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
7062
58
2
+ Added@valjoux/util-bitwise@0.1.11(transitive)
- Removed@valjoux/util-bitwise@0.0.6(transitive)
Updated@valjoux/util-bitwise@^0.1.0