diff --git a/.github/workflows/nodejs-14.yml b/.github/workflows/nodejs-14.yml
new file mode 100644
index 0000000..b87ccdd
--- /dev/null
+++ b/.github/workflows/nodejs-14.yml
@@ -0,0 +1,22 @@
+name: Node.js 14 CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Use Node.js
+ uses: irby/setup-node-nvm@master
+ with:
+ node-version: '16.x'
+ - run: npm install
+ - run: npm run prepublishOnly
+ - run: node -v
+ - run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 && node -v && npm run test-local
diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index 0374854..075facf 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -3,7 +3,6 @@ name: CI
on:
push:
branches: [ master ]
-
pull_request:
branches: [ master ]
@@ -13,4 +12,4 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest'
- version: '16, 18, 20, 21'
+ version: '16, 18, 20, 22'
diff --git a/.gitignore b/.gitignore
index db8d971..3bd7051 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,4 @@ npm-debug.log
.nyc_output
.tshy*
dist
+package-lock.json
diff --git a/README.md b/README.md
index 6e8c525..ef6d8cc 100644
--- a/README.md
+++ b/README.md
@@ -315,19 +315,12 @@ new Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)
Fastest is utils.datestruct().YYYYMMDD
```
-
-
-## Contributors
-
-|[
fengmk2](https://github.com/fengmk2)
|[
dead-horse](https://github.com/dead-horse)
|[
alsotang](https://github.com/alsotang)
|[
popomore](https://github.com/popomore)
|[
gxcsoccer](https://github.com/gxcsoccer)
|[
danielsss](https://github.com/danielsss)
|
-| :---: | :---: | :---: | :---: | :---: | :---: |
-|[
XadillaX](https://github.com/XadillaX)
|[
ulivz](https://github.com/ulivz)
|[
mosikoo](https://github.com/mosikoo)
|[
leoner](https://github.com/leoner)
|[
legend80s](https://github.com/legend80s)
|[
semantic-release-bot](https://github.com/semantic-release-bot)
|
-[
ddzy](https://github.com/ddzy)
|[
zhanghengyao](https://github.com/zhanghengyao)
+## License
-This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Dec 11 2023 00:23:06 GMT+0800`.
+[MIT](LICENSE.txt)
-
+## Contributors
-## License
+[![Contributors](https://contrib.rocks/image?repo=node-modules/utility)](https://github.com/node-modules/utility/graphs/contributors)
-[MIT](LICENSE.txt)
+Made with [contributors-img](https://contrib.rocks).
diff --git a/package.json b/package.json
index 91eca79..8a2f1d1 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,6 @@
"test-local": "egg-bin test",
"preci": "npm run prepublishOnly",
"ci": "egg-bin cov",
- "contributor": "git-contributor",
"prepublishOnly": "tshy && tshy-after"
},
"dependencies": {
@@ -20,20 +19,18 @@
"@eggjs/tsconfig": "^1.3.3",
"@types/escape-html": "^1.0.4",
"@types/mocha": "^10.0.6",
- "@types/node": "^20.10.0",
+ "@types/node": "22",
"beautify-benchmark": "^0.2.4",
"benchmark": "^2.1.4",
- "contributors": "*",
"egg-bin": "^6.5.2",
"eslint": "^8.54.0",
"eslint-config-egg": "^13.0.0",
- "git-contributor": "^2.1.5",
"moment": "^2.22.2",
"object-assign": "^4.1.1",
"optimized": "^1.2.0",
"time-require": "^0.1.2",
"tsd": "^0.28.1",
- "tshy": "^1.8.1",
+ "tshy": "^3.0.2",
"tshy-after": "^1.0.0",
"typescript": "^5.2.2"
},
@@ -81,5 +78,6 @@
"src"
],
"main": "./dist/commonjs/index.js",
- "types": "./dist/commonjs/index.d.ts"
+ "types": "./dist/commonjs/index.d.ts",
+ "module": "./dist/esm/index.js"
}
diff --git a/src/date.ts b/src/date.ts
index 926a14e..c40145d 100644
--- a/src/date.ts
+++ b/src/date.ts
@@ -33,7 +33,11 @@ const MONTHS: Record = {
'12': 'Dec',
};
-function getDateStringParts(d: Date, onlyDate?: boolean) {
+/**
+ * return `[ YYYY, MM, DD, HH, mm, ss ]` date string array
+ */
+export function getDateStringParts(d?: Date, onlyDate?: boolean) {
+ d = d || new Date();
const monthNum = d.getMonth() + 1;
const month = monthNum < 10 ? `0${monthNum}` : `${monthNum}`;
const dateNum = d.getDate();
diff --git a/test/date.test.ts b/test/date.test.ts
index 7981aca..06a95ef 100644
--- a/test/date.test.ts
+++ b/test/date.test.ts
@@ -2,9 +2,16 @@ import { strict as assert } from 'node:assert';
import moment from 'moment';
import * as utility from '../src/index.js';
import * as utils from '../src/index.js';
-import { YYYYMMDDHHmmss, logDate } from '../src/index.js';
+import { YYYYMMDDHHmmss, logDate, getDateStringParts } from '../src/index.js';
describe('test/date.test.ts', () => {
+ describe('getDateStringParts()', () => {
+ it('should work', () => {
+ assert.match(getDateStringParts().join(','), /^\d{4},\d{2},\d{2},\d{2},\d{2},\d{2}$/);
+ assert.match(utility.getDateStringParts(new Date(), true).join('.'), /^\d{4}\.\d{2}\.\d{2}$/);
+ });
+ });
+
describe('YYYYMMDDHHmmss()', () => {
it('should return an "YYYY-MM-DD HH:mm:ss" format date string', () => {
assert.match(utility.YYYYMMDDHHmmss(), /^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}$/);