Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Вершинин Андрей #152

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions roman-time.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
'use strict';
var hours = parseInt(process.argv[2], 10);
var minutes = parseInt(process.argv[3],10);

/**
* @param {String} time – время в формате HH:MM (например, 09:05)
* @returns {String} – время римскими цифрами (IX:V)
*/
function romanTime(time) {
// Немного авторского кода и замечательной магии
return time;
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;