From 7aa9590fec3a638bc7609b516ec3c34447cd141f Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 21:33:55 +0500 Subject: [PATCH 01/36] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=B5=20?= =?UTF-8?q?=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/roman-time.js b/roman-time.js index f66353e..3d8cbad 100644 --- a/roman-time.js +++ b/roman-time.js @@ -6,6 +6,58 @@ */ function romanTime(time) { // Немного авторского кода и замечательной магии + var romantime; + var timeSplit =time.split(':'); + if (timeSplit[0]>23 ||timeSplit[0]<0 || timeSplit[1]>59 || timeSplit[1]<0 ){ + + throw new TypeError; + } + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ + throw new TypeError; + + } + if (timeSplit[0]==NaN ||timeSplit[0]===undefined || timeSplit[1]==NaN || timeSplit[1]===undefined ){ + + throw new TypeError; + + } + var cifri=['N','I','II','III','IV','V','VI','VII','VIII','IX']; + var cifrii=['N','X','XX','XXX','XL','L'] + var a=timeSplit[0].split(''); + var b=timeSplit[1].split(''); + var hours; + var minutes; + parseInt(a[0],10); + parseInt(a[1],10); + parseInt(b[0],10); + parseInt(b[1],10); + + if (a[0]==0 && a[1]==0){ + hours=cifri[0]; + } if(a[0]==0 && a[1]!=0){ + hours=cifri[a[1]]; + } if(a[0]!=0 && a[1]!=0){ + hours=cifrii[(a[0])]+cifri[a[1]]; + } + if(a[0]!=0 && a[1]==0){ + hours=cifrii[a[0]]; + } + + + if (b[0]==0 && b[1]==0){ + minutes=cifri[0]; + } if(b[0]==0 && b[1]!=0){ + minutes=cifri[b[1]]; + } if(b[0]!=0 && b[1]!=0){ + minutes=cifrii[(b[0]/10)]+cifri[b[1]]; + } + if(b[0]!=0 && b[1]==0){ + minutes=cifrii[b[0]]; + } + if(minutes==''){ + new TypeError(); + } + time=hours+':'+minutes return time; } From eb021d8d8982567144b753c4da20a98634f7e632 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 21:50:57 +0500 Subject: [PATCH 02/36] =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=80=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/roman-time.js b/roman-time.js index 3d8cbad..b4d48eb 100644 --- a/roman-time.js +++ b/roman-time.js @@ -6,17 +6,15 @@ */ function romanTime(time) { // Немного авторского кода и замечательной магии - var romantime; var timeSplit =time.split(':'); - if (timeSplit[0]>23 ||timeSplit[0]<0 || timeSplit[1]>59 || timeSplit[1]<0 ){ - + if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ throw new TypeError; } if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ throw new TypeError; } - if (timeSplit[0]==NaN ||timeSplit[0]===undefined || timeSplit[1]==NaN || timeSplit[1]===undefined ){ + if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ throw new TypeError; @@ -32,26 +30,26 @@ function romanTime(time) { parseInt(b[0],10); parseInt(b[1],10); - if (a[0]==0 && a[1]==0){ + if (a[0] == 0 && a[1] == 0){ hours=cifri[0]; - } if(a[0]==0 && a[1]!=0){ + } if(a[0] == 0 && a[1] != 0){ hours=cifri[a[1]]; - } if(a[0]!=0 && a[1]!=0){ + } if(a[0] != 0 && a[1] != 0){ hours=cifrii[(a[0])]+cifri[a[1]]; } - if(a[0]!=0 && a[1]==0){ + if(a[0] != 0 && a[1] == 0){ hours=cifrii[a[0]]; } - if (b[0]==0 && b[1]==0){ + if (b[0] == 0 && b[1] == 0){ minutes=cifri[0]; - } if(b[0]==0 && b[1]!=0){ + } if(b[0] == 0 && b[1] != 0){ minutes=cifri[b[1]]; - } if(b[0]!=0 && b[1]!=0){ + } if(b[0] != 0 && b[1] != 0){ minutes=cifrii[(b[0]/10)]+cifri[b[1]]; } - if(b[0]!=0 && b[1]==0){ + if(b[0] != 0 && b[1] == 0){ minutes=cifrii[b[0]]; } if(minutes==''){ From 153a6cd9d68e6c5e8290bf8724ba874684b204c0 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 21:58:14 +0500 Subject: [PATCH 03/36] =?UTF-8?q?=E2=84=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 94 ++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/roman-time.js b/roman-time.js index b4d48eb..155fbdb 100644 --- a/roman-time.js +++ b/roman-time.js @@ -7,56 +7,50 @@ function romanTime(time) { // Немного авторского кода и замечательной магии var timeSplit =time.split(':'); - if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ - throw new TypeError; - } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ - throw new TypeError; - - } - if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ - - throw new TypeError; - - } - var cifri=['N','I','II','III','IV','V','VI','VII','VIII','IX']; - var cifrii=['N','X','XX','XXX','XL','L'] - var a=timeSplit[0].split(''); - var b=timeSplit[1].split(''); - var hours; - var minutes; - parseInt(a[0],10); - parseInt(a[1],10); - parseInt(b[0],10); - parseInt(b[1],10); - - if (a[0] == 0 && a[1] == 0){ - hours=cifri[0]; - } if(a[0] == 0 && a[1] != 0){ - hours=cifri[a[1]]; - } if(a[0] != 0 && a[1] != 0){ - hours=cifrii[(a[0])]+cifri[a[1]]; - } - if(a[0] != 0 && a[1] == 0){ - hours=cifrii[a[0]]; - } - - - if (b[0] == 0 && b[1] == 0){ - minutes=cifri[0]; - } if(b[0] == 0 && b[1] != 0){ - minutes=cifri[b[1]]; - } if(b[0] != 0 && b[1] != 0){ - minutes=cifrii[(b[0]/10)]+cifri[b[1]]; - } - if(b[0] != 0 && b[1] == 0){ - minutes=cifrii[b[0]]; - } - if(minutes==''){ - new TypeError(); - } - time=hours+':'+minutes - return time; + if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ + throw new TypeError; + } + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ + throw new TypeError; + } + if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ + throw new TypeError; + } + var cifri=['N','I','II','III','IV','V','VI','VII','VIII','IX']; + var cifrii=['N','X','XX','XXX','XL','L'] + var a = timeSplit[0].split(''); + var b = timeSplit[1].split(''); + var hours; + var minutes; + parseInt(a[0],10); + parseInt(a[1],10); + parseInt(b[0],10); + parseInt(b[1],10); + if (a[0] == 0 && a[1] == 0){ + hours = cifri[0]; + } if(a[0] == 0 && a[1] != 0){ + hours = cifri[a[1]]; + } if(a[0] != 0 && a[1] != 0){ + hours = cifrii[(a[0])]+cifri[a[1]]; + } + if(a[0] != 0 && a[1] == 0){ + hours = cifrii[a[0]]; + } + if (b[0] == 0 && b[1] == 0){ + minutes = cifri[0]; + } if(b[0] == 0 && b[1] != 0){ + minutes = cifri[b[1]]; + } if(b[0] != 0 && b[1] != 0){ + minutes = cifrii[(b[0]/10)]+cifri[b[1]]; + } + if(b[0] != 0 && b[1] == 0){ + minutes = cifrii[b[0]]; + } + if(minutes == ''){ + new TypeError(); + } + time = hours+':'+minutes + return time; } module.exports = romanTime; From edafab95ff274d794becaa8d0b846b4cac25c8dc Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 22:05:07 +0500 Subject: [PATCH 04/36] =?UTF-8?q?=E2=84=964?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/roman-time.js b/roman-time.js index 155fbdb..4b99e3d 100644 --- a/roman-time.js +++ b/roman-time.js @@ -31,7 +31,7 @@ function romanTime(time) { } if(a[0] == 0 && a[1] != 0){ hours = cifri[a[1]]; } if(a[0] != 0 && a[1] != 0){ - hours = cifrii[(a[0])]+cifri[a[1]]; + hours = cifrii[(a[0])] + cifri[a[1]]; } if(a[0] != 0 && a[1] == 0){ hours = cifrii[a[0]]; @@ -41,7 +41,7 @@ function romanTime(time) { } if(b[0] == 0 && b[1] != 0){ minutes = cifri[b[1]]; } if(b[0] != 0 && b[1] != 0){ - minutes = cifrii[(b[0]/10)]+cifri[b[1]]; + minutes = cifrii[(b[0]/10)] + cifri[b[1]]; } if(b[0] != 0 && b[1] == 0){ minutes = cifrii[b[0]]; @@ -49,8 +49,9 @@ function romanTime(time) { if(minutes == ''){ new TypeError(); } - time = hours+':'+minutes - return time; + time = hours + ':' + minutes; + + return time; } module.exports = romanTime; From f9d9d0ac2f504948dfd9259306a89c42befff5f5 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 22:24:17 +0500 Subject: [PATCH 05/36] =?UTF-8?q?=E2=84=965?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 69 +++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/roman-time.js b/roman-time.js index 4b99e3d..117d070 100644 --- a/roman-time.js +++ b/roman-time.js @@ -5,53 +5,30 @@ * @returns {String} – время римскими цифрами (IX:V) */ function romanTime(time) { - // Немного авторского кода и замечательной магии - var timeSplit =time.split(':'); - if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ - throw new TypeError; - } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ - throw new TypeError; - } - if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ - throw new TypeError; - } - var cifri=['N','I','II','III','IV','V','VI','VII','VIII','IX']; - var cifrii=['N','X','XX','XXX','XL','L'] - var a = timeSplit[0].split(''); - var b = timeSplit[1].split(''); - var hours; - var minutes; - parseInt(a[0],10); - parseInt(a[1],10); - parseInt(b[0],10); - parseInt(b[1],10); - if (a[0] == 0 && a[1] == 0){ - hours = cifri[0]; - } if(a[0] == 0 && a[1] != 0){ - hours = cifri[a[1]]; - } if(a[0] != 0 && a[1] != 0){ - hours = cifrii[(a[0])] + cifri[a[1]]; - } - if(a[0] != 0 && a[1] == 0){ - hours = cifrii[a[0]]; - } - if (b[0] == 0 && b[1] == 0){ - minutes = cifri[0]; - } if(b[0] == 0 && b[1] != 0){ - minutes = cifri[b[1]]; - } if(b[0] != 0 && b[1] != 0){ - minutes = cifrii[(b[0]/10)] + cifri[b[1]]; - } - if(b[0] != 0 && b[1] == 0){ - minutes = cifrii[b[0]]; - } - if(minutes == ''){ - new TypeError(); - } - time = hours + ':' + minutes; + var timeSplit =time.split(':'); + if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){throw new TypeError; } + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){throw new TypeError; } + if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){throw new TypeError; } + var cifri = ['N','I','II','III','IV','V','VI','VII','VIII','IX']; + var cifrii = ['N','X','XX','XXX','XL','L']; + var a = timeSplit[0].split(''); + var b = timeSplit[1].split(''); + parseInt(a[0],10); + parseInt(a[1],10); + parseInt(b[0],10); + parseInt(b[1],10); + if (a[0] == 0 && a[1] == 0){var hours = cifri[0]; } + if (a[0] == 0 && a[1] != 0){hours = cifri[a[1]]; } + if (a[0] != 0 && a[1] != 0){hours = cifrii[(a[0])] + cifri[a[1]]; } + if (a[0] != 0 && a[1] == 0){hours = cifrii[a[0]]; } + if (b[0] == 0 && b[1] == 0){var minutes = cifri[0]; } + if(b[0] == 0 && b[1] != 0){minutes = cifri[b[1]]; } + if(b[0] != 0 && b[1] != 0){minutes = cifrii[(b[0]/10)] + cifri[b[1]]; } + if(b[0] != 0 && b[1] == 0){minutes = cifrii[b[0]]; } + if(minutes == ''){new TypeError();} + time = hours + ':' + minutes; - return time; + return time; } module.exports = romanTime; From 2bacbcf21877e12a28932b900a59a8c06720f84f Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 22:44:01 +0500 Subject: [PATCH 06/36] =?UTF-8?q?=E2=84=966?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/roman-time.js b/roman-time.js index 117d070..0da94dd 100644 --- a/roman-time.js +++ b/roman-time.js @@ -4,29 +4,33 @@ * @param {String} time – время в формате HH:MM (например, 09:05) * @returns {String} – время римскими цифрами (IX:V) */ +function roman(time){ + var timeSplit =time.split(':'); + var cifri = ['N','I','II','III','IV','V','VI','VII','VIII','IX']; + var cifrii = ['N','X','XX','XXX','XL','L']; + var a = timeSplit[0].split(''); + parseInt(a[0],10); + parseInt(a[1],10); + if (a[0] == 0 && a[1] == 0){ var hours = cifri[0]; } + if (a[0] == 0 && a[1] !== 0){ hours = cifri[a[1]]; } + if (a[0] !== 0 && a[1] !== 0){ hours = cifrii[(a[0])] + cifri[a[1]]; } + if (a[0] !== 0 && a[1] == 0){ hours = cifrii[a[0]]; } +} function romanTime(time) { - var timeSplit =time.split(':'); - if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){throw new TypeError; } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){throw new TypeError; } - if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){throw new TypeError; } - var cifri = ['N','I','II','III','IV','V','VI','VII','VIII','IX']; - var cifrii = ['N','X','XX','XXX','XL','L']; - var a = timeSplit[0].split(''); - var b = timeSplit[1].split(''); - parseInt(a[0],10); - parseInt(a[1],10); - parseInt(b[0],10); - parseInt(b[1],10); - if (a[0] == 0 && a[1] == 0){var hours = cifri[0]; } - if (a[0] == 0 && a[1] != 0){hours = cifri[a[1]]; } - if (a[0] != 0 && a[1] != 0){hours = cifrii[(a[0])] + cifri[a[1]]; } - if (a[0] != 0 && a[1] == 0){hours = cifrii[a[0]]; } - if (b[0] == 0 && b[1] == 0){var minutes = cifri[0]; } - if(b[0] == 0 && b[1] != 0){minutes = cifri[b[1]]; } - if(b[0] != 0 && b[1] != 0){minutes = cifrii[(b[0]/10)] + cifri[b[1]]; } - if(b[0] != 0 && b[1] == 0){minutes = cifrii[b[0]]; } - if(minutes == ''){new TypeError();} - time = hours + ':' + minutes; + var timeSplit =time.split(':'); + if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ throw new TypeError(); } + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ throw new TypeError(); } + if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ throw new TypeError();} + var cifri = ['N','I','II','III','IV','V','VI','VII','VIII','IX']; + var cifrii = ['N','X','XX','XXX','XL','L']; + var b = timeSplit[1].split(''); + parseInt(b[0],10); + parseInt(b[1],10); + if (b[0] == 0 && b[1] == 0){ var minutes = cifri[0]; } + if (b[0] == 0 && b[1] !== 0){ minutes = cifri[b[1]]; } + if (b[0] !== 0 && b[1] !== 0){ minutes = cifrii[(b[0]/10)] + cifri[b[1]]; } + if (b[0] !== 0 && b[1] == 0){ minutes = cifrii[b[0]]; } + time = roman(time) + ':' + minutes; return time; } From f1e721882005cbf711563bf6db261d160e61b158 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 22:59:14 +0500 Subject: [PATCH 07/36] =?UTF-8?q?=E2=84=967?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/roman-time.js b/roman-time.js index 0da94dd..d5fe91c 100644 --- a/roman-time.js +++ b/roman-time.js @@ -1,13 +1,12 @@ 'use strict'; - + cifri = ['N', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']; + cifrii = ['N', 'X', 'XX', 'XXX', 'XL', 'L']; /** * @param {String} time – время в формате HH:MM (например, 09:05) * @returns {String} – время римскими цифрами (IX:V) */ -function roman(time){ +function roman(time) { var timeSplit =time.split(':'); - var cifri = ['N','I','II','III','IV','V','VI','VII','VIII','IX']; - var cifrii = ['N','X','XX','XXX','XL','L']; var a = timeSplit[0].split(''); parseInt(a[0],10); parseInt(a[1],10); @@ -20,9 +19,7 @@ function romanTime(time) { var timeSplit =time.split(':'); if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ throw new TypeError(); } if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ throw new TypeError(); } - if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ throw new TypeError();} - var cifri = ['N','I','II','III','IV','V','VI','VII','VIII','IX']; - var cifrii = ['N','X','XX','XXX','XL','L']; + if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ throw new TypeError();} var b = timeSplit[1].split(''); parseInt(b[0],10); parseInt(b[1],10); From aaedb084194e26e7337ddd8d559346a0081b967f Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:11:21 +0500 Subject: [PATCH 08/36] =?UTF-8?q?=E2=84=968?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/roman-time.js b/roman-time.js index d5fe91c..17d7334 100644 --- a/roman-time.js +++ b/roman-time.js @@ -1,19 +1,22 @@ 'use strict'; - cifri = ['N', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']; - cifrii = ['N', 'X', 'XX', 'XXX', 'XL', 'L']; +var cifri = ['N', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']; +var cifrii = ['N', 'X', 'XX', 'XXX', 'XL', 'L']; + /** * @param {String} time – время в формате HH:MM (например, 09:05) * @returns {String} – время римскими цифрами (IX:V) */ function roman(time) { - var timeSplit =time.split(':'); + var timeSplit = time.split(':'); var a = timeSplit[0].split(''); - parseInt(a[0],10); - parseInt(a[1],10); - if (a[0] == 0 && a[1] == 0){ var hours = cifri[0]; } - if (a[0] == 0 && a[1] !== 0){ hours = cifri[a[1]]; } - if (a[0] !== 0 && a[1] !== 0){ hours = cifrii[(a[0])] + cifri[a[1]]; } - if (a[0] !== 0 && a[1] == 0){ hours = cifrii[a[0]]; } + parseInt(a[0], 10); + parseInt(a[1], 10); + if (a[0] == 0 && a[1] == 0) { var hours = cifri[0]; } + if (a[0] == 0 && a[1] !== 0) { hours = cifri[a[1]]; } + if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } + if (a[0] !== 0 && a[1] == 0) { hours = cifrii[a[0]]; } + + return hours; } function romanTime(time) { var timeSplit =time.split(':'); From df5e91fd46815d493c127fb3631de9a7985495ea Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:19:28 +0500 Subject: [PATCH 09/36] =?UTF-8?q?=E2=84=969?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 54 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/roman-time.js b/roman-time.js index 17d7334..c3734bd 100644 --- a/roman-time.js +++ b/roman-time.js @@ -11,28 +11,50 @@ function roman(time) { var a = timeSplit[0].split(''); parseInt(a[0], 10); parseInt(a[1], 10); - if (a[0] == 0 && a[1] == 0) { var hours = cifri[0]; } - if (a[0] == 0 && a[1] !== 0) { hours = cifri[a[1]]; } - if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } - if (a[0] !== 0 && a[1] == 0) { hours = cifrii[a[0]]; } + if (a[0] == 0 && a[1] == 0) { + var hours = cifri[0]; + } + if (a[0] == 0 && a[1] !== 0) { + hours = cifri[a[1]]; + } + if (a[0] !== 0 && a[1] !== 0) { + hours = cifrii[(a[0])] + cifri[a[1]]; + } + if (a[0] !== 0 && a[1] == 0) { + hours = cifrii[a[0]]; + } return hours; } function romanTime(time) { var timeSplit =time.split(':'); - if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ throw new TypeError(); } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ throw new TypeError(); } - if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ throw new TypeError();} - var b = timeSplit[1].split(''); - parseInt(b[0],10); - parseInt(b[1],10); - if (b[0] == 0 && b[1] == 0){ var minutes = cifri[0]; } - if (b[0] == 0 && b[1] !== 0){ minutes = cifri[b[1]]; } - if (b[0] !== 0 && b[1] !== 0){ minutes = cifrii[(b[0]/10)] + cifri[b[1]]; } - if (b[0] !== 0 && b[1] == 0){ minutes = cifrii[b[0]]; } - time = roman(time) + ':' + minutes; + if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ + throw new TypeError(); + } + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ + throw new TypeError(); + } + if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ + throw new TypeError(); + } + var b = timeSplit[1].split(''); + parseInt(b[0], 10); + parseInt(b[1], 10); + if (b[0] == 0 && b[1] == 0) { + var minutes = cifri[0]; + } + if (b[0] == 0 && b[1] !== 0) { + minutes = cifri[b[1]]; + } + if (b[0] !== 0 && b[1] !== 0) { + minutes = cifrii[(b[0]/10)] + cifri[b[1]]; + } + if (b[0] !== 0 && b[1] == 0) { + minutes = cifrii[b[0]]; + } + time = roman(time) + ':' + minutes; - return time; + return time; } module.exports = romanTime; From 68407e83a859659b09c85df7c9c3d2492d880324 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:29:44 +0500 Subject: [PATCH 10/36] =?UTF-8?q?=E2=84=969?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/roman-time.js b/roman-time.js index c3734bd..c0d6b9d 100644 --- a/roman-time.js +++ b/roman-time.js @@ -9,18 +9,19 @@ var cifrii = ['N', 'X', 'XX', 'XXX', 'XL', 'L']; function roman(time) { var timeSplit = time.split(':'); var a = timeSplit[0].split(''); + var hours; parseInt(a[0], 10); parseInt(a[1], 10); - if (a[0] == 0 && a[1] == 0) { - var hours = cifri[0]; + if (a[0] === 0 && a[1] === 0) { + hours = cifri[0]; } - if (a[0] == 0 && a[1] !== 0) { + if (a[0] === 0 && a[1] !== 0) { hours = cifri[a[1]]; } if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } - if (a[0] !== 0 && a[1] == 0) { + if (a[0] !== 0 && a[1] === 0) { hours = cifrii[a[0]]; } @@ -28,28 +29,29 @@ function roman(time) { } function romanTime(time) { var timeSplit =time.split(':'); + var minutes; if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ throw new TypeError(); } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ + if (isNaN (timeSplit[0]) || isNaN (timeSplit[1])){ throw new TypeError(); } - if (timeSplit[0] == NaN || timeSplit[0] === undefined || timeSplit[1] == NaN || timeSplit[1] === undefined ){ + if (timeSplit[0] === undefined || timeSplit[1] === undefined ){ throw new TypeError(); } var b = timeSplit[1].split(''); parseInt(b[0], 10); parseInt(b[1], 10); - if (b[0] == 0 && b[1] == 0) { - var minutes = cifri[0]; + if (b[0] === 0 && b[1] === 0) { + minutes = cifri[0]; } - if (b[0] == 0 && b[1] !== 0) { + if (b[0] === 0 && b[1] !== 0) { minutes = cifri[b[1]]; } if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0]/10)] + cifri[b[1]]; } - if (b[0] !== 0 && b[1] == 0) { + if (b[0] !== 0 && b[1] === 0) { minutes = cifrii[b[0]]; } time = roman(time) + ':' + minutes; From 5256bd7c4ec3de83262007ff761b53e1626a1800 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:35:43 +0500 Subject: [PATCH 11/36] =?UTF-8?q?=E2=84=9610?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/roman-time.js b/roman-time.js index c0d6b9d..8b5c76b 100644 --- a/roman-time.js +++ b/roman-time.js @@ -24,21 +24,21 @@ function roman(time) { if (a[0] !== 0 && a[1] === 0) { hours = cifrii[a[0]]; } - + return hours; } function romanTime(time) { - var timeSplit =time.split(':'); + var timeSplit = time.split(':'); var minutes; - if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0 ){ + if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0) { throw new TypeError(); } - if (isNaN (timeSplit[0]) || isNaN (timeSplit[1])){ + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ throw new TypeError(); } - if (timeSplit[0] === undefined || timeSplit[1] === undefined ){ + if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); - } + } var b = timeSplit[1].split(''); parseInt(b[0], 10); parseInt(b[1], 10); @@ -49,13 +49,13 @@ function romanTime(time) { minutes = cifri[b[1]]; } if (b[0] !== 0 && b[1] !== 0) { - minutes = cifrii[(b[0]/10)] + cifri[b[1]]; + minutes = cifrii[(b[0] / 10)] + cifri[b[1]]; } if (b[0] !== 0 && b[1] === 0) { minutes = cifrii[b[0]]; } time = roman(time) + ':' + minutes; - + return time; } From 818adfc677e25fa22814d8893385a170e122c8d2 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:41:23 +0500 Subject: [PATCH 12/36] =?UTF-8?q?=E2=84=9611?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/roman-time.js b/roman-time.js index 8b5c76b..89d51aa 100644 --- a/roman-time.js +++ b/roman-time.js @@ -10,6 +10,9 @@ function roman(time) { var timeSplit = time.split(':'); var a = timeSplit[0].split(''); var hours; + if (timeSplit[0] > 23 || timeSplit[0] < 0) { + throw new TypeError(); + } parseInt(a[0], 10); parseInt(a[1], 10); if (a[0] === 0 && a[1] === 0) { @@ -30,10 +33,10 @@ function roman(time) { function romanTime(time) { var timeSplit = time.split(':'); var minutes; - if (timeSplit[0] > 23 || timeSplit[0] < 0 || timeSplit[1] > 59 || timeSplit[1] < 0) { + if (timeSplit[1] > 59 || timeSplit[1] < 0) { throw new TypeError(); } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])){ + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { throw new TypeError(); } if (timeSplit[0] === undefined || timeSplit[1] === undefined) { From b1392b852a0c38137e9556e6089b255600cec44c Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:51:51 +0500 Subject: [PATCH 13/36] =?UTF-8?q?=E2=84=9611?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/roman-time.js b/roman-time.js index 89d51aa..7330a76 100644 --- a/roman-time.js +++ b/roman-time.js @@ -1,14 +1,15 @@ 'use strict'; var cifri = ['N', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']; var cifrii = ['N', 'X', 'XX', 'XXX', 'XL', 'L']; +var timeSplit = time.split(':'); +var a = timeSplit[0].split(''); +var minutes; /** * @param {String} time – время в формате HH:MM (например, 09:05) * @returns {String} – время римскими цифрами (IX:V) */ -function roman(time) { - var timeSplit = time.split(':'); - var a = timeSplit[0].split(''); +function roman(time) { var hours; if (timeSplit[0] > 23 || timeSplit[0] < 0) { throw new TypeError(); @@ -31,8 +32,6 @@ function roman(time) { return hours; } function romanTime(time) { - var timeSplit = time.split(':'); - var minutes; if (timeSplit[1] > 59 || timeSplit[1] < 0) { throw new TypeError(); } From 706347c5a682627e3073b1f119c4427f4467ddc5 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Wed, 12 Oct 2016 23:58:29 +0500 Subject: [PATCH 14/36] =?UTF-8?q?=E2=84=9612?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/roman-time.js b/roman-time.js index 7330a76..4d5a904 100644 --- a/roman-time.js +++ b/roman-time.js @@ -1,16 +1,16 @@ 'use strict'; var cifri = ['N', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']; var cifrii = ['N', 'X', 'XX', 'XXX', 'XL', 'L']; -var timeSplit = time.split(':'); -var a = timeSplit[0].split(''); +var hours; var minutes; /** * @param {String} time – время в формате HH:MM (например, 09:05) * @returns {String} – время римскими цифрами (IX:V) */ -function roman(time) { - var hours; +function roman(time) { + var timeSplit = time.split(':'); + var a = timeSplit[0].split(''); if (timeSplit[0] > 23 || timeSplit[0] < 0) { throw new TypeError(); } @@ -32,13 +32,8 @@ function roman(time) { return hours; } function romanTime(time) { - if (timeSplit[1] > 59 || timeSplit[1] < 0) { - throw new TypeError(); - } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { - throw new TypeError(); - } - if (timeSplit[0] === undefined || timeSplit[1] === undefined) { + var timeSplit = time.split(':'); + if (timeSplit[1] > 59 || timeSplit[1] < 0 || isNaN(timeSplit[0]) || isNaN(timeSplit[1]) || timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } var b = timeSplit[1].split(''); @@ -51,7 +46,7 @@ function romanTime(time) { minutes = cifri[b[1]]; } if (b[0] !== 0 && b[1] !== 0) { - minutes = cifrii[(b[0] / 10)] + cifri[b[1]]; + minutes = cifrii[(b[0])] + cifri[b[1]]; } if (b[0] !== 0 && b[1] === 0) { minutes = cifrii[b[0]]; From cfef813399d7595efdeb16ae485b6712c0a948c0 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:05:48 +0500 Subject: [PATCH 15/36] =?UTF-8?q?=E2=84=9613?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roman-time.js b/roman-time.js index 4d5a904..375275b 100644 --- a/roman-time.js +++ b/roman-time.js @@ -25,7 +25,7 @@ function roman(time) { if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } - if (a[0] !== 0 && a[1] === 0) { + else { hours = cifrii[a[0]]; } @@ -33,7 +33,8 @@ function roman(time) { } function romanTime(time) { var timeSplit = time.split(':'); - if (timeSplit[1] > 59 || timeSplit[1] < 0 || isNaN(timeSplit[0]) || isNaN(timeSplit[1]) || timeSplit[0] === undefined || timeSplit[1] === undefined) { + if (timeSplit[1] > 59 || timeSplit[1] < 0 || isNaN(timeSplit[0]) || isNaN(timeSplit[1]) + || timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } var b = timeSplit[1].split(''); @@ -48,12 +49,11 @@ function romanTime(time) { if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } - if (b[0] !== 0 && b[1] === 0) { + else { minutes = cifrii[b[0]]; } - time = roman(time) + ':' + minutes; - return time; + return (roman(time) + ':' + minutes); } module.exports = romanTime; From 6afa5f361a12042e8a59f47ad84e8839cfa8338b Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:14:52 +0500 Subject: [PATCH 16/36] =?UTF-8?q?=E2=84=9614?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/roman-time.js b/roman-time.js index 375275b..768bc60 100644 --- a/roman-time.js +++ b/roman-time.js @@ -10,7 +10,7 @@ var minutes; */ function roman(time) { var timeSplit = time.split(':'); - var a = timeSplit[0].split(''); + var a = timeSplit[0].split(''); if (timeSplit[0] > 23 || timeSplit[0] < 0) { throw new TypeError(); } @@ -25,19 +25,19 @@ function roman(time) { if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } - else { + else + { hours = cifrii[a[0]]; } return hours; } -function romanTime(time) { +function roman1(time) { var timeSplit = time.split(':'); - if (timeSplit[1] > 59 || timeSplit[1] < 0 || isNaN(timeSplit[0]) || isNaN(timeSplit[1]) - || timeSplit[0] === undefined || timeSplit[1] === undefined) { + var a = timeSplit[0].split(''); + if (timeSplit[0] > 59 || timeSplit[0] < 0) { throw new TypeError(); } - var b = timeSplit[1].split(''); parseInt(b[0], 10); parseInt(b[1], 10); if (b[0] === 0 && b[1] === 0) { @@ -49,11 +49,21 @@ function romanTime(time) { if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } - else { + else + { minutes = cifrii[b[0]]; } - return (roman(time) + ':' + minutes); + return minutes; +} +function romanTime(time) { + var timeSplit = time.split(':'); + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1]) || timeSplit[0] === undefined || timeSplit[1] === undefined) { + throw new TypeError(); + } + var b = timeSplit[1].split(''); + + return (roman(time) + ':' + roman1(time)); } module.exports = romanTime; From d84cedded3288a469340158ff4190d3c5a608928 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:20:46 +0500 Subject: [PATCH 17/36] =?UTF-8?q?=E2=84=9615?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/roman-time.js b/roman-time.js index 768bc60..b70d4a9 100644 --- a/roman-time.js +++ b/roman-time.js @@ -22,7 +22,8 @@ function roman(time) { if (a[0] === 0 && a[1] !== 0) { hours = cifri[a[1]]; } - if (a[0] !== 0 && a[1] !== 0) { + if (a[0] !== 0 && a[1] !== 0) + { hours = cifrii[(a[0])] + cifri[a[1]]; } else @@ -34,7 +35,7 @@ function roman(time) { } function roman1(time) { var timeSplit = time.split(':'); - var a = timeSplit[0].split(''); + var b = timeSplit[1].split(''); if (timeSplit[0] > 59 || timeSplit[0] < 0) { throw new TypeError(); } @@ -58,7 +59,10 @@ function roman1(time) { } function romanTime(time) { var timeSplit = time.split(':'); - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1]) || timeSplit[0] === undefined || timeSplit[1] === undefined) { + if (timeSplit[0] === undefined || timeSplit[1] === undefined) { + throw new TypeError(); + } + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { throw new TypeError(); } var b = timeSplit[1].split(''); From be4daf4ec6d3d2ab96eb896f719cb473a84fd052 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:27:29 +0500 Subject: [PATCH 18/36] =?UTF-8?q?=E2=84=9616?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/roman-time.js b/roman-time.js index b70d4a9..5ab13d4 100644 --- a/roman-time.js +++ b/roman-time.js @@ -26,8 +26,7 @@ function roman(time) { { hours = cifrii[(a[0])] + cifri[a[1]]; } - else - { + else { hours = cifrii[a[0]]; } @@ -50,8 +49,7 @@ function roman1(time) { if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } - else - { + else { minutes = cifrii[b[0]]; } @@ -59,13 +57,13 @@ function roman1(time) { } function romanTime(time) { var timeSplit = time.split(':'); + var b = timeSplit[1].split(''); if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { + if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { throw new TypeError(); } - var b = timeSplit[1].split(''); return (roman(time) + ':' + roman1(time)); } From 89e1ce9adcd458fb59bfe06eba6ae443ad2ce48c Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:31:59 +0500 Subject: [PATCH 19/36] =?UTF-8?q?=E2=84=9617?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/roman-time.js b/roman-time.js index 5ab13d4..0eef602 100644 --- a/roman-time.js +++ b/roman-time.js @@ -22,13 +22,11 @@ function roman(time) { if (a[0] === 0 && a[1] !== 0) { hours = cifri[a[1]]; } - if (a[0] !== 0 && a[1] !== 0) - { + if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } else { - hours = cifrii[a[0]]; - } + hours = cifrii[a[0]];} return hours; } @@ -50,14 +48,12 @@ function roman1(time) { minutes = cifrii[(b[0])] + cifri[b[1]]; } else { - minutes = cifrii[b[0]]; - } + minutes = cifrii[b[0]];} return minutes; } function romanTime(time) { - var timeSplit = time.split(':'); - var b = timeSplit[1].split(''); + var timeSplit = time.split(':'); if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } From e985a04e732d14bcde757c41370fb05d2e52a2d6 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:36:42 +0500 Subject: [PATCH 20/36] =?UTF-8?q?=E2=84=9618?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/roman-time.js b/roman-time.js index 0eef602..e2ce452 100644 --- a/roman-time.js +++ b/roman-time.js @@ -24,9 +24,8 @@ function roman(time) { } if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; - } - else { - hours = cifrii[a[0]];} + } else { + hours = cifrii[a[0]]; } return hours; } @@ -46,14 +45,13 @@ function roman1(time) { } if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; - } - else { - minutes = cifrii[b[0]];} + } else { + minutes = cifrii[b[0]]; } return minutes; } function romanTime(time) { - var timeSplit = time.split(':'); + var timeSplit = time.split(':'); if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } From e69bbe5b3bfd6002ce18afe876c028ce5d2eabca Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:39:22 +0500 Subject: [PATCH 21/36] =?UTF-8?q?=E2=84=9619?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roman-time.js b/roman-time.js index e2ce452..414f92a 100644 --- a/roman-time.js +++ b/roman-time.js @@ -25,7 +25,8 @@ function roman(time) { if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } else { - hours = cifrii[a[0]]; } + hours = cifrii[a[0]]; + } return hours; } @@ -46,7 +47,8 @@ function roman1(time) { if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } else { - minutes = cifrii[b[0]]; } + minutes = cifrii[b[0]]; + } return minutes; } From 7ec5d989cf804cbcca48259cf8e2e0b4cfbf0c6c Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 00:54:56 +0500 Subject: [PATCH 22/36] =?UTF-8?q?=E2=84=9619?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roman-time.js b/roman-time.js index 414f92a..79897f2 100644 --- a/roman-time.js +++ b/roman-time.js @@ -18,15 +18,17 @@ function roman(time) { parseInt(a[1], 10); if (a[0] === 0 && a[1] === 0) { hours = cifri[0]; - } + } else { if (a[0] === 0 && a[1] !== 0) { hours = cifri[a[1]]; - } + } else { if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } else { hours = cifrii[a[0]]; } + } + } return hours; } @@ -40,15 +42,17 @@ function roman1(time) { parseInt(b[1], 10); if (b[0] === 0 && b[1] === 0) { minutes = cifri[0]; - } + } else { if (b[0] === 0 && b[1] !== 0) { minutes = cifri[b[1]]; - } + } else{ if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } else { minutes = cifrii[b[0]]; } + } + } return minutes; } From 437c734a01cfe06580eb7e23ae6d04865d65ef05 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 01:20:47 +0500 Subject: [PATCH 23/36] =?UTF-8?q?=E2=84=9620?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/roman-time.js b/roman-time.js index 79897f2..7100bb8 100644 --- a/roman-time.js +++ b/roman-time.js @@ -16,19 +16,17 @@ function roman(time) { } parseInt(a[0], 10); parseInt(a[1], 10); - if (a[0] === 0 && a[1] === 0) { + if (a[0] == 0 && a[1] == 0) { hours = cifri[0]; - } else { - if (a[0] === 0 && a[1] !== 0) { + } + if (a[0] == 0 && a[1] != 0) { hours = cifri[a[1]]; - } else { - if (a[0] !== 0 && a[1] !== 0) { + } + if (a[0] != 0 && a[1] != 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } else { hours = cifrii[a[0]]; } - } - } return hours; } @@ -40,25 +38,23 @@ function roman1(time) { } parseInt(b[0], 10); parseInt(b[1], 10); - if (b[0] === 0 && b[1] === 0) { + if (b[0] == 0 && b[1] == 0) { minutes = cifri[0]; - } else { - if (b[0] === 0 && b[1] !== 0) { + } + if (b[0] == 0 && b[1] != 0) { minutes = cifri[b[1]]; - } else{ - if (b[0] !== 0 && b[1] !== 0) { + } + if (b[0] != 0 && b[1] != 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } else { minutes = cifrii[b[0]]; } - } - } return minutes; } function romanTime(time) { var timeSplit = time.split(':'); - if (timeSplit[0] === undefined || timeSplit[1] === undefined) { + if (timeSplit[0] == undefined || timeSplit[1] == undefined) { throw new TypeError(); } if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { From e774389fbbaa87857680b31d839baeded06daf83 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 01:33:43 +0500 Subject: [PATCH 24/36] =?UTF-8?q?=E2=84=9621?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roman-time.js b/roman-time.js index 7100bb8..fcb614e 100644 --- a/roman-time.js +++ b/roman-time.js @@ -16,13 +16,13 @@ function roman(time) { } parseInt(a[0], 10); parseInt(a[1], 10); - if (a[0] == 0 && a[1] == 0) { + if (a[0] === '0' && a[1] === '0') { hours = cifri[0]; } - if (a[0] == 0 && a[1] != 0) { + if (a[0] === '0' && a[1] !== '0') { hours = cifri[a[1]]; } - if (a[0] != 0 && a[1] != 0) { + if (a[0] !== '0' && a[1] !== '0') { hours = cifrii[(a[0])] + cifri[a[1]]; } else { hours = cifrii[a[0]]; @@ -38,13 +38,13 @@ function roman1(time) { } parseInt(b[0], 10); parseInt(b[1], 10); - if (b[0] == 0 && b[1] == 0) { + if (b[0] === '0' && b[1] === '0') { minutes = cifri[0]; } - if (b[0] == 0 && b[1] != 0) { + if (b[0] === '0' && b[1] !== '0') { minutes = cifri[b[1]]; } - if (b[0] != 0 && b[1] != 0) { + if (b[0] !== '0' && b[1] !== '0') { minutes = cifrii[(b[0])] + cifri[b[1]]; } else { minutes = cifrii[b[0]]; From bae681a527555ae0b43242d6705fc7954a7d129e Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 01:35:01 +0500 Subject: [PATCH 25/36] =?UTF-8?q?=E2=84=9622?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roman-time.js b/roman-time.js index fcb614e..d5c9210 100644 --- a/roman-time.js +++ b/roman-time.js @@ -54,7 +54,7 @@ function roman1(time) { } function romanTime(time) { var timeSplit = time.split(':'); - if (timeSplit[0] == undefined || timeSplit[1] == undefined) { + if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { From 52f1fc1d90e5de00f441f48959d092884f4cfbbc Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 01:55:56 +0500 Subject: [PATCH 26/36] =?UTF-8?q?=E2=84=9623?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/roman-time.js b/roman-time.js index d5c9210..dad35c4 100644 --- a/roman-time.js +++ b/roman-time.js @@ -18,15 +18,17 @@ function roman(time) { parseInt(a[1], 10); if (a[0] === '0' && a[1] === '0') { hours = cifri[0]; - } + } else { if (a[0] === '0' && a[1] !== '0') { - hours = cifri[a[1]]; - } + hours = cifri[a[1]-5]; + } else { if (a[0] !== '0' && a[1] !== '0') { hours = cifrii[(a[0])] + cifri[a[1]]; } else { hours = cifrii[a[0]]; } + } + } return hours; } From f9f7b865a3ba888736b7c0b4de6a9123c820d9e7 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 02:04:55 +0500 Subject: [PATCH 27/36] =?UTF-8?q?=E2=84=9625?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roman-time.js b/roman-time.js index dad35c4..907048c 100644 --- a/roman-time.js +++ b/roman-time.js @@ -20,7 +20,7 @@ function roman(time) { hours = cifri[0]; } else { if (a[0] === '0' && a[1] !== '0') { - hours = cifri[a[1]-5]; + hours = cifrii[a[1]]; } else { if (a[0] !== '0' && a[1] !== '0') { hours = cifrii[(a[0])] + cifri[a[1]]; @@ -44,7 +44,7 @@ function roman1(time) { minutes = cifri[0]; } if (b[0] === '0' && b[1] !== '0') { - minutes = cifri[b[1]]; + minutes = cifrii[b[1]]; } if (b[0] !== '0' && b[1] !== '0') { minutes = cifrii[(b[0])] + cifri[b[1]]; From 52069bcd3fc07ebd598fc83f15e2b8daa4955e2a Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 02:07:09 +0500 Subject: [PATCH 28/36] =?UTF-8?q?=E2=84=9626?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/roman-time.js b/roman-time.js index 907048c..bc0bd90 100644 --- a/roman-time.js +++ b/roman-time.js @@ -16,19 +16,17 @@ function roman(time) { } parseInt(a[0], 10); parseInt(a[1], 10); - if (a[0] === '0' && a[1] === '0') { + if (a[0] === 0 && a[1] === 0) { hours = cifri[0]; - } else { - if (a[0] === '0' && a[1] !== '0') { + } + if (a[0] === 0 && a[1] !== 0) { hours = cifrii[a[1]]; - } else { - if (a[0] !== '0' && a[1] !== '0') { + } + if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } else { hours = cifrii[a[0]]; } - } - } return hours; } @@ -40,13 +38,13 @@ function roman1(time) { } parseInt(b[0], 10); parseInt(b[1], 10); - if (b[0] === '0' && b[1] === '0') { + if (b[0] === 0 && b[1] === 0) { minutes = cifri[0]; } - if (b[0] === '0' && b[1] !== '0') { + if (b[0] === 0 && b[1] !== 0) { minutes = cifrii[b[1]]; } - if (b[0] !== '0' && b[1] !== '0') { + if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } else { minutes = cifrii[b[0]]; From bd7eb6dcf4add09e1b5c8a3603bf0e2bfcf04d8c Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:03:23 +0500 Subject: [PATCH 29/36] =?UTF-8?q?=E2=84=9627?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/roman-time.js b/roman-time.js index bc0bd90..88bf242 100644 --- a/roman-time.js +++ b/roman-time.js @@ -11,11 +11,8 @@ var minutes; function roman(time) { var timeSplit = time.split(':'); var a = timeSplit[0].split(''); - if (timeSplit[0] > 23 || timeSplit[0] < 0) { - throw new TypeError(); - } - parseInt(a[0], 10); - parseInt(a[1], 10); + a[0] = parseInt(a[0], 10); + a[1] = parseInt(a[1], 10); if (a[0] === 0 && a[1] === 0) { hours = cifri[0]; } @@ -24,7 +21,8 @@ function roman(time) { } if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; - } else { + } + if (a[0] !== 0 && a[1] === 0){ hours = cifrii[a[0]]; } @@ -33,11 +31,9 @@ function roman(time) { function roman1(time) { var timeSplit = time.split(':'); var b = timeSplit[1].split(''); - if (timeSplit[0] > 59 || timeSplit[0] < 0) { - throw new TypeError(); - } - parseInt(b[0], 10); - parseInt(b[1], 10); + + b[0] = parseInt(b[0], 10); + b[1] = parseInt(b[1], 10); if (b[0] === 0 && b[1] === 0) { minutes = cifri[0]; } @@ -46,7 +42,8 @@ function roman1(time) { } if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; - } else { + } + if (b[0] !== 0 && b[1] === 0){ minutes = cifrii[b[0]]; } @@ -54,10 +51,13 @@ function roman1(time) { } function romanTime(time) { var timeSplit = time.split(':'); + if (timeSplit[0] > 23 || timeSplit[0] < 0 || isNaN(timeSplit[0])) { + throw new TypeError(); + } if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } - if (isNaN(timeSplit[0]) || isNaN(timeSplit[1])) { + if (timeSplit[0] > 59 || timeSplit[0] < 0 || isNaN(timeSplit[1])) { throw new TypeError(); } From d7b9646d8535d885889f0567cf6e83c2a002511a Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:08:52 +0500 Subject: [PATCH 30/36] =?UTF-8?q?=E2=84=9628?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/roman-time.js b/roman-time.js index 88bf242..1932e04 100644 --- a/roman-time.js +++ b/roman-time.js @@ -11,7 +11,7 @@ var minutes; function roman(time) { var timeSplit = time.split(':'); var a = timeSplit[0].split(''); - a[0] = parseInt(a[0], 10); + a[0] = parseInt(a[0], 10); a[1] = parseInt(a[1], 10); if (a[0] === 0 && a[1] === 0) { hours = cifri[0]; @@ -22,7 +22,7 @@ function roman(time) { if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; } - if (a[0] !== 0 && a[1] === 0){ + if (a[0] !== 0 && a[1] === 0) { hours = cifrii[a[0]]; } @@ -32,7 +32,7 @@ function roman1(time) { var timeSplit = time.split(':'); var b = timeSplit[1].split(''); - b[0] = parseInt(b[0], 10); + b[0] = parseInt(b[0], 10); b[1] = parseInt(b[1], 10); if (b[0] === 0 && b[1] === 0) { minutes = cifri[0]; @@ -43,17 +43,23 @@ function roman1(time) { if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; } - if (b[0] !== 0 && b[1] === 0){ + if (b[0] !== 0 && b[1] === 0) { minutes = cifrii[b[0]]; } return minutes; } -function romanTime(time) { - var timeSplit = time.split(':'); +function romanTime1(time){ + var timeSplit = time.split(':'); if (timeSplit[0] > 23 || timeSplit[0] < 0 || isNaN(timeSplit[0])) { throw new TypeError(); } + + return (1); +} +function romanTime(time) { + var timeSplit = time.split(':'); + romanTime1(time); if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } From 098c296c424dd39110e4b21951f28e0edaad9b3c Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:11:23 +0500 Subject: [PATCH 31/36] =?UTF-8?q?=E2=84=9629?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roman-time.js b/roman-time.js index 1932e04..f1769f3 100644 --- a/roman-time.js +++ b/roman-time.js @@ -49,8 +49,8 @@ function roman1(time) { return minutes; } -function romanTime1(time){ - var timeSplit = time.split(':'); +function romanTime1(time) { + var timeSplit = time.split(':'); if (timeSplit[0] > 23 || timeSplit[0] < 0 || isNaN(timeSplit[0])) { throw new TypeError(); } From cb6743a32299c1086ced67e4b52ef23d08a0839b Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:14:07 +0500 Subject: [PATCH 32/36] =?UTF-8?q?=E2=84=9630?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roman-time.js b/roman-time.js index f1769f3..6d8fce8 100644 --- a/roman-time.js +++ b/roman-time.js @@ -17,7 +17,7 @@ function roman(time) { hours = cifri[0]; } if (a[0] === 0 && a[1] !== 0) { - hours = cifrii[a[1]]; + hours = cifri[a[1]]; } if (a[0] !== 0 && a[1] !== 0) { hours = cifrii[(a[0])] + cifri[a[1]]; @@ -38,7 +38,7 @@ function roman1(time) { minutes = cifri[0]; } if (b[0] === 0 && b[1] !== 0) { - minutes = cifrii[b[1]]; + minutes = cifri[b[1]]; } if (b[0] !== 0 && b[1] !== 0) { minutes = cifrii[(b[0])] + cifri[b[1]]; From c83e8f2313955d652a1b063340a4c98dd43d646c Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:23:56 +0500 Subject: [PATCH 33/36] JSGO --- roman-time.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/roman-time.js b/roman-time.js index 6d8fce8..1a54a33 100644 --- a/roman-time.js +++ b/roman-time.js @@ -57,13 +57,22 @@ function romanTime1(time) { return (1); } +function romanTime2(time) { + var timeSplit = time.split(':'); + if (timeSplit[0].length !== 2) { + throw new TypeError(); + } + + return (1); +} function romanTime(time) { var timeSplit = time.split(':'); romanTime1(time); + romanTime2(time); if (timeSplit[0] === undefined || timeSplit[1] === undefined) { throw new TypeError(); } - if (timeSplit[0] > 59 || timeSplit[0] < 0 || isNaN(timeSplit[1])) { + if (timeSplit[1] > 59 || timeSplit[1] < 0 || isNaN(timeSplit[1])) { throw new TypeError(); } From 8b42cbde57cd92d5b2fca00677778d815f45a1ea Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:34:09 +0500 Subject: [PATCH 34/36] GO --- roman-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roman-time.js b/roman-time.js index 1a54a33..74b8e95 100644 --- a/roman-time.js +++ b/roman-time.js @@ -59,7 +59,7 @@ function romanTime1(time) { } function romanTime2(time) { var timeSplit = time.split(':'); - if (timeSplit[0].length !== 2) { + if (timeSplit[0].length !== 2 || timeSplit[1].length !== 2) { throw new TypeError(); } From bef999e94543521b17092007ce9c6c98c9ecdd28 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Thu, 13 Oct 2016 03:53:30 +0500 Subject: [PATCH 35/36] GO1 --- roman-time.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/roman-time.js b/roman-time.js index 74b8e95..863eb15 100644 --- a/roman-time.js +++ b/roman-time.js @@ -69,9 +69,6 @@ function romanTime(time) { var timeSplit = time.split(':'); romanTime1(time); romanTime2(time); - if (timeSplit[0] === undefined || timeSplit[1] === undefined) { - throw new TypeError(); - } if (timeSplit[1] > 59 || timeSplit[1] < 0 || isNaN(timeSplit[1])) { throw new TypeError(); } From 706495938e56db56e3eb2551cfb2cdcc3d3788e6 Mon Sep 17 00:00:00 2001 From: LopatinNikolai Date: Fri, 14 Oct 2016 17:46:20 +0500 Subject: [PATCH 36/36] GG --- roman-time.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roman-time.js b/roman-time.js index 863eb15..2d52e68 100644 --- a/roman-time.js +++ b/roman-time.js @@ -51,6 +51,12 @@ function roman1(time) { } function romanTime1(time) { var timeSplit = time.split(':'); + var a = timeSplit[0].split(''); + a[0] = parseInt(a[0], 10); + a[1] = parseInt(a[1], 10); + if (isNaN(a[0]) || isNaN(a[1])) { + throw new TypeError(); + } if (timeSplit[0] > 23 || timeSplit[0] < 0 || isNaN(timeSplit[0])) { throw new TypeError(); } @@ -59,6 +65,12 @@ function romanTime1(time) { } function romanTime2(time) { var timeSplit = time.split(':'); + var b = timeSplit[1].split(''); + b[0] = parseInt(b[0], 10); + b[1] = parseInt(b[1], 10); + if (isNaN(b[0]) || isNaN(b[1])) { + throw new TypeError(); + } if (timeSplit[0].length !== 2 || timeSplit[1].length !== 2) { throw new TypeError(); }