lunar-lite
Advanced tools
Comparing version 0.0.1 to 0.0.2
import { LunarDate, SolarDate } from "./types"; | ||
/** | ||
* 将日期字符串 YYYY-MM-DD 或者一个 Date 对象分割为 [YYYY, M - 1, D] | ||
* 将日期字符串 YYYY-MM-DD 或者一个 Date 对象分割为 [YYYY, M, D, H, m, s] | ||
* 当参数为字符串时分割符可以是 `-` `.` 或者 `/` | ||
@@ -5,0 +5,0 @@ * |
@@ -8,3 +8,3 @@ "use strict"; | ||
/** | ||
* 将日期字符串 YYYY-MM-DD 或者一个 Date 对象分割为 [YYYY, M - 1, D] | ||
* 将日期字符串 YYYY-MM-DD 或者一个 Date 对象分割为 [YYYY, M, D, H, m, s] | ||
* 当参数为字符串时分割符可以是 `-` `.` 或者 `/` | ||
@@ -19,9 +19,16 @@ * | ||
if (date instanceof Date) { | ||
return [date.getFullYear(), date.getMonth() + 1, date.getDate()]; | ||
return [ | ||
date.getFullYear(), | ||
date.getMonth() + 1, | ||
date.getDate(), | ||
date.getHours(), | ||
date.getMinutes(), | ||
date.getSeconds(), | ||
]; | ||
} | ||
var result = date | ||
.split(/[. -/]/) | ||
.filter(function (word) { return word !== ""; }) | ||
.map(function (word) { return +word.trim(); }); | ||
return result; | ||
return date | ||
.split(/[ ]+/) | ||
.map(function (item) { return item.split(/[-:/.]/); }) | ||
.reduce(function (prev, next) { return prev.concat(next); }, []) | ||
.map(function (item) { return +item; }); | ||
}; | ||
@@ -28,0 +35,0 @@ exports.normalizeDateStr = normalizeDateStr; |
{ | ||
"name": "lunar-lite", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "精简版的农历和阳历日期转换库。", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
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
58937
1567