Skip to content

Commit 34b783d

Browse files
re-formate with standard.js
1 parent 479973b commit 34b783d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Conversions/RailwayTimeConversion.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
The time conversion of normalized time to the railway is a simple algorithm
3-
because we know that if the time is in 'AM' value it means they only want
4-
some changes on hours and minutes and if the time in 'PM' it means the only
2+
The time conversion of normalized time to the railway is a simple algorithm
3+
because we know that if the time is in 'AM' value it means they only want
4+
some changes on hours and minutes and if the time in 'PM' it means the only
55
want some changes in hour value.
66
77
Input Formate -> 07:05:45PM
@@ -16,20 +16,20 @@
1616
* @returns {String} Railway time string.
1717
*/
1818
const RailwayTimeConversion = (timeString) => {
19-
// firstly, check that input is a string or not.
20-
if (typeof timeString !== 'string') {
21-
return new TypeError('Argument is not a string.')
22-
}
23-
// split the string by ':' character.
24-
const [hour, minute, scondWithShift] = timeString.split(':')
25-
// split second and shift value.
26-
const [second, shift] = [scondWithShift.substr(0, 2), scondWithShift.substr(2)]
27-
// convert shifted time to not-shift time(Railway time) by using the above explanation.
28-
if (shift === 'PM') {
29-
if (parseInt(hour) === 12) { return `${hour}:${minute}:${second}` } else { return `${parseInt(hour) + 12}:${minute}:${second}` }
30-
} else {
31-
if (parseInt(hour) === 12) { return `00:${minute}:${second}` } else { return `${hour}:${minute}:${second}` }
32-
}
19+
// firstly, check that input is a string or not.
20+
if (typeof timeString !== 'string') {
21+
return new TypeError('Argument is not a string.')
22+
}
23+
// split the string by ':' character.
24+
const [hour, minute, scondWithShift] = timeString.split(':')
25+
// split second and shift value.
26+
const [second, shift] = [scondWithShift.substr(0, 2), scondWithShift.substr(2)]
27+
// convert shifted time to not-shift time(Railway time) by using the above explanation.
28+
if (shift === 'PM') {
29+
if (parseInt(hour) === 12) { return `${hour}:${minute}:${second}` } else { return `${parseInt(hour) + 12}:${minute}:${second}` }
30+
} else {
31+
if (parseInt(hour) === 12) { return `00:${minute}:${second}` } else { return `${hour}:${minute}:${second}` }
32+
}
3333
}
3434

3535
module.exports = RailwayTimeConversion

0 commit comments

Comments
 (0)