Skip to content

Commit

Permalink
refactor(ontime): factor out regex for time representation
Browse files Browse the repository at this point in the history
  • Loading branch information
mycoboco committed Aug 17, 2016
1 parent bfffb92 commit 465ab4e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 1 addition & 5 deletions index.js
Expand Up @@ -7,11 +7,7 @@
var nextime = require('./lib/nextime')


var fmt = {
norm: /^(?:(?:(?:(?:(?:(\d{4})-)?(\d{1,2})-)?(\d{1,2})\D)?(\d{1,2}):)?(\d{1,2}):)?(\d{1,2})$/,
week: /^[a-z]+\s(\d{1,2}:\d{1,2}:\d{1,2})$/i
}

var fmt = require('./lib/fmt')
var idcnt = 0


Expand Down
13 changes: 13 additions & 0 deletions lib/fmt.js
@@ -0,0 +1,13 @@
/*
* regular expressions to recognize time representations
*/

'use strict'


module.exports = {
norm: /^(?:(?:(?:(?:(?:(\d{4})-)?(\d{1,2})-)?(\d{1,2})\D)?(\d{1,2}):)?(\d{1,2}):)?(\d{1,2})$/,
week: /^[a-z]+\s(\d{1,2}:\d{1,2}:\d{1,2})$/i
}

// end of fmt.js
2 changes: 1 addition & 1 deletion lib/nextime.js
Expand Up @@ -5,7 +5,7 @@
'use strict'


var fmt = /^(?:(?:(?:(?:(?:(\d{4})-)?(\d{1,2})-)?(\d{1,2})\D)?(\d{1,2}):)?(\d{1,2}):)?(\d{1,2})$/
var fmt = require('./fmt').norm


module.exports = function (cycle, s, now, utc, last) {
Expand Down

0 comments on commit 465ab4e

Please sign in to comment.