Skip to content

Commit 5865c19

Browse files
committed
.
0 parents  commit 5865c19

10 files changed

+256
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
// warnings
7+
"no-unused-expressions": 1,
8+
"no-warning-comments": 1,
9+
"no-native-reassign": 1,
10+
"no-invalid-regexp": 1,
11+
"no-debugger": 1,
12+
"no-console": 1,
13+
"no-empty": 1,
14+
"radix": 1,
15+
16+
// errors
17+
"no-shadow-restricted-names": 2,
18+
"handle-callback-err": 2,
19+
"no-self-compare": 2,
20+
"no-empty-class": 2,
21+
"no-unused-vars": 2,
22+
"no-dupe-keys": 2,
23+
"valid-typeof": 2,
24+
"no-undef": 2,
25+
26+
// stylistic errors
27+
"quotes": [2, "single", "avoid-escape"],
28+
"no-space-before-semi": 2,
29+
"space-unary-word-ops": 2,
30+
"no-spaced-func": 2,
31+
"yoda": "always",
32+
"new-cap": 2,
33+
34+
// mute
35+
"no-use-before-define": 0,
36+
"eol-last": 0,
37+
"strict": 0,
38+
"eqeqeq": 0,
39+
"curly": 0
40+
}
41+
}

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# tmp files
2+
lib-cov
3+
*.seed
4+
*.log
5+
*.csv
6+
*.dat
7+
*.out
8+
*.pid
9+
*.gz
10+
11+
# tmp folders
12+
pids/
13+
logs/
14+
results/
15+
coverage/
16+
17+
# node.js
18+
node_modules/
19+
npm-debug.log
20+
21+
# osx
22+
.DS_Store

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_js:
2+
- "0.10"
3+
- "0.11"
4+
language: node_js
5+
script: "make test-travis"
6+
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
SRC = index.js
2+
3+
include node_modules/make-lint/index.mk
4+
5+
LINT_CONFIG = .eslintrc
6+
TESTS = test.js
7+
8+
test: lint
9+
@NODE_ENV=test ./node_modules/.bin/mocha \
10+
$(TESTS) \
11+
--bail
12+
13+
test-cov:
14+
@NODE_ENV=test node \
15+
node_modules/.bin/istanbul cover \
16+
./node_modules/.bin/_mocha \
17+
-- -u exports \
18+
$(TESTS) \
19+
--bail
20+
21+
test-travis:
22+
@NODE_ENV=test node \
23+
node_modules/.bin/istanbul cover \
24+
./node_modules/.bin/_mocha \
25+
--report lcovonly \
26+
-- -u exports \
27+
$(TESTS) \
28+
--bail
29+
30+
.PHONY: test

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# regex-iso-date
2+
[![NPM version][npm-image]][npm-url]
3+
[![build status][travis-image]][travis-url]
4+
[![Test coverage][coveralls-image]][coveralls-url]
5+
[![Downloads][downloads-image]][downloads-url]
6+
7+
Regular expression for ISO date.
8+
9+
## Installation
10+
```bash
11+
npm install regex-iso-date
12+
```
13+
14+
## Usage
15+
16+
```js
17+
var regex = require('regex-iso-date');
18+
19+
regex().test('2011-10-05T14:48:00.000Z');
20+
// => true
21+
22+
var match = regex().exec('2011-10-05T14:48:00.000Z');
23+
match[0] // => '2011-10-05T14:48:00.000Z'
24+
match[1] // => '2011'
25+
match[2] // => '10'
26+
match[3] // => '05'
27+
match[4] // => '14:48:00'
28+
match[5] // => '14'
29+
match[6] // => '48'
30+
match[7] // => '00'
31+
match[8] // => '000'
32+
```
33+
34+
## Contributors
35+
- [Yoshua Wuyts](https://github.com/yoshuawuyts)
36+
- [Hugh Kennedy](https://github.com/hughsk)
37+
- [Jon Schlinkert](https://github.com/jonschlinkert)
38+
39+
## See Also
40+
- [Date.prototype.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
41+
42+
## License
43+
[MIT](https://tldrlegal.com/license/mit-license)
44+
45+
[npm-image]: https://img.shields.io/npm/v/regex-iso-date.svg?style=flat-square
46+
[npm-url]: https://npmjs.org/package/regex-iso-date
47+
[travis-image]: https://img.shields.io/travis/regexps/regex-iso-date.svg?style=flat-square
48+
[travis-url]: https://travis-ci.org/regexps/regex-iso-date
49+
[coveralls-image]: https://img.shields.io/coveralls/regexps/regex-iso-date.svg?style=flat-square
50+
[coveralls-url]: https://coveralls.io/r/regexps/regex-iso-date?branch=master
51+
[downloads-image]: http://img.shields.io/npm/dm/regex-iso-date.svg?style=flat-square
52+
[downloads-url]: https://npmjs.org/package/regex-iso-date

index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Expose UTC regex.
3+
*
4+
* Example input:
5+
* 2011-10-05T14:48:00.000Z
6+
*/
7+
module.exports = function() {
8+
return /(\d{4})-(\d{2})-(\d{2})T((\d{2}):(\d{2}):(\d{2}))\.(\d{3})Z/;
9+
};

package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "regex-iso-date",
3+
"version": "1.0.0",
4+
"description": "Regular expression for ISO date",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "make test"
8+
},
9+
"repository": "regexps/regex-iso-date",
10+
"keywords": [
11+
"date",
12+
"regular expression",
13+
"regex",
14+
"regexp",
15+
"time",
16+
"iso"
17+
],
18+
"license": "MIT",
19+
"dependencies": {},
20+
"devDependencies": {
21+
"istanbul": "^0.3.5",
22+
"make-lint": "^1.0.1",
23+
"mocha": "^2.0.1"
24+
},
25+
"files": [
26+
"LICENSE",
27+
"index.js",
28+
"README.md"
29+
]
30+
}

test.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Module dependencies
3+
*/
4+
var assert = require('assert');
5+
var regex = require('./');
6+
7+
/**
8+
* Test
9+
*/
10+
describe('utc regex', function() {
11+
it('should match iso input', function() {
12+
assert.equal(regex().test('2011-10-05T14:48:00.000Z'), true);
13+
});
14+
15+
it('should expose match groups', function() {
16+
var match = regex().exec('2011-10-05T14:48:00.000Z');
17+
assert.equal(match[0], '2011-10-05T14:48:00.000Z');
18+
assert.equal(match[1], '2011');
19+
assert.equal(match[2], '10');
20+
assert.equal(match[3], '05');
21+
assert.equal(match[4], '14:48:00');
22+
assert.equal(match[5], '14');
23+
assert.equal(match[6], '48');
24+
assert.equal(match[7], '00');
25+
assert.equal(match[8], '000');
26+
});
27+
28+
it('should catch incorrect input', function() {
29+
assert.equal(regex().test('201-10-05T14:48:00.000Z'), false);
30+
assert.equal(regex().test('2011-10-05T14:48:00.00Z'), false);
31+
});
32+
});

0 commit comments

Comments
 (0)