From 36bef3396b9fe79abb4f8f8fbf02d16377048052 Mon Sep 17 00:00:00 2001 From: andreyu008 Date: Fri, 14 Oct 2016 23:54:28 +0500 Subject: [PATCH 1/2] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=20=D1=80?= =?UTF-8?q?=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/roman-time.js b/roman-time.js index f66353e..b2c91ef 100644 --- a/roman-time.js +++ b/roman-time.js @@ -4,9 +4,28 @@ * @param {String} time – время в формате HH:MM (например, 09:05) * @returns {String} – время римскими цифрами (IX:V) */ -function romanTime(time) { - // Немного авторского кода и замечательной магии - return time; +var hours = parseInt(process.argv[2], 10); +var minutes = parseInt(process.argv[3],10); + +function romanTime(time){ + var tens = Math.floor(time / 10) * 10; + var units = time - tens; + var hours = romans[tens] + romans[units]; + return hours; } +if (hours >= 0 && hours <=23 && minutes >=0 && minutes<=59) { + + var romans = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X']; + romans [20] = 'XX'; + romans [30] = 'XXX'; + romans [40] = 'XL'; + romans [50] = 'L'; + var romanHours = romanTime(hours); + var romanMinutes=romanTime(minutes); + + console.log(hours === 0 ? '-' : romanHours, romanMinutes); +} else{ + console.log('Время указанно неверно'); +} module.exports = romanTime; From 4e1d7d7ce0a524466d8684b2e4ee20c3a24d8424 Mon Sep 17 00:00:00 2001 From: andreyu008 Date: Sat, 15 Oct 2016 13:18:45 +0500 Subject: [PATCH 2/2] =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roman-time.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/roman-time.js b/roman-time.js index b2c91ef..0630873 100644 --- a/roman-time.js +++ b/roman-time.js @@ -1,9 +1,4 @@ 'use strict'; - -/** - * @param {String} time – время в формате HH:MM (например, 09:05) - * @returns {String} – время римскими цифрами (IX:V) - */ var hours = parseInt(process.argv[2], 10); var minutes = parseInt(process.argv[3],10);