Skip to content

Commit 6ae0f72

Browse files
committed
fix(precision): support nanoseconds
Add support for nanosecond precision. Also some minor tooling config changes to test a new thing out. Signed-off-by: Jonathan Garbee <jonathan@garbee.me>
1 parent e9b8681 commit 6ae0f72

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

etc/eslintrc.cjs .eslintrc.cjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
],
1212
env: {
1313
'es2020': true,
14+
'node': true,
1415
},
1516
parserOptions: {
1617
sourceType: 'module',
@@ -19,6 +20,7 @@ module.exports = {
1920
'max-len': ['error', {
2021
code: 60,
2122
ignoreRegExpLiterals: true,
22-
}]
23+
ignoreUrls: true,
24+
}],
2325
},
2426
};

.markdownlint.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Autoformatter friendly markdownlint config (all formatting rules disabled)
2+
default: true
3+
blank_lines: false
4+
bullet: false
5+
html: false
6+
indentation: false
7+
line_length: false
8+
spaces: false
9+
url: false
10+
whitespace: false

.trunk/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*out
2+
*logs
3+
plugins
4+
user_trunk.yaml

.trunk/trunk.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 0.1
2+
cli:
3+
version: 0.16.1-beta
4+
lint:
5+
disabled:
6+
- prettier
7+
enabled:
8+
- actionlint@1.6.15
9+
- git-diff-check@SYSTEM
10+
- gitleaks@8.11.0
11+
- markdownlint@0.32.1
12+
- eslint@8.22.0

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "tsc",
99
"test": "c8 --config=etc/c8rc.json ava --config=etc/ava.config.mjs",
10-
"lint": "eslint --config=etc/eslintrc.cjs --ext=.ts src tests"
10+
"lint": "eslint --ext=.ts src tests"
1111
},
1212
"author": "Jonathan Garbee <jonathan@garbee.me>",
1313
"license": "Unlicense",

src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ const minutePattern = /(?<minute>[0-5]\d)/;
3737
const secondsPattern = /(?<seconds>([0-5]\d)|60)/;
3838
/**
3939
* Millisesconds have no defined precision.
40-
* Allowing for up to 8 since this has been seen from Java.
41-
* It may increase if another language allows for more
42-
* specificity than that.
43-
* From 0-99999999.
40+
* Allowing for up to 9 since this gets to nanoseconds.
41+
* Going beyond nanoseconds seems unreasonable to expect:
42+
* https://nickb.dev/blog/iso8601-and-nanosecond-precision-across-languages/
43+
* From 0-999999999.
4444
* The period to denote them is required if MS are present.
4545
*/
46-
const millisecondsPattern = /(?:\.(?<milliseconds>\d{1,8}))?/;
46+
const millisecondsPattern = /(?:\.(?<milliseconds>\d{1,9}))?/;
4747

4848
/**
4949
* Timezone is complex and difficult to break down further

0 commit comments

Comments
 (0)