File tree Expand file tree Collapse file tree 2 files changed +11
-21
lines changed
Expand file tree Collapse file tree 2 files changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -64,33 +64,16 @@ class Time {
6464 ) ;
6565 }
6666
67- respond ( result ) {
68- if ( Number . isNaN ( result [ 0 ] ) ) {
69- return new Error ( 'Unrecognised time' ) ;
70- }
71-
72- return result ;
73- }
74-
7567 get original ( ) {
76- return this . respond ( [
77- this . timeObject . getHours ( ) ,
78- this . timeObject . getMinutes ( ) ,
79- ] ) ;
68+ return [ this . timeObject . getHours ( ) , this . timeObject . getMinutes ( ) ] ;
8069 }
8170
8271 get utc ( ) {
83- return this . respond ( [
84- this . timeObjectUTC . getHours ( ) ,
85- this . timeObjectUTC . getMinutes ( ) ,
86- ] ) ;
72+ return [ this . timeObjectUTC . getHours ( ) , this . timeObjectUTC . getMinutes ( ) ] ;
8773 }
8874
8975 get local ( ) {
90- return this . respond ( [
91- this . timeObjectLocal . getHours ( ) ,
92- this . timeObjectLocal . getMinutes ( ) ,
93- ] ) ;
76+ return [ this . timeObjectLocal . getHours ( ) , this . timeObjectLocal . getMinutes ( ) ] ;
9477 }
9578
9679 get timezones ( ) {
@@ -114,5 +97,12 @@ module.exports = input => {
11497 timezone : formattedInputArr [ 4 ] || 'utc' ,
11598 } ;
11699
100+ if (
101+ Number . isNaN ( formattedInput . hours ) ||
102+ Number . isNaN ( formattedInput . minutes )
103+ ) {
104+ return new Error ( 'Unrecognised time' ) ;
105+ }
106+
117107 return new Time ( formattedInput ) ;
118108} ;
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ test('wrong arg', t => {
4545
4646test ( 'throw if unrecognised' , t => {
4747 const res = tizo ( '' ) ;
48- t . is ( res , 'Unrecognised time' ) ;
48+ t . deepEqual ( res , new Error ( 'Unrecognised time' ) ) ;
4949} ) ;
5050
5151test ( 'am/pm' , t => {
You can’t perform that action at this time.
0 commit comments