Last active
November 13, 2017 17:46
-
-
Save Swivelgames/c80e1e0dd5fcbef577331696df3f885c to your computer and use it in GitHub Desktop.
Revisions
-
Swivelgames revised this gist
Nov 13, 2017 . 1 changed file with 6 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,16 +5,9 @@ const toTwelveHour = time => { } /* expanded utility */ const toTwelveHour = (time) => { const [hour, min] = time.split(':'); const suffix = hour > 12 ? 'PM' : 'AM'; const hr = hour > 12 ? hour - 12 : parseInt(hour, 10); return `${hr === 0 ? 12 : hr}:${min}${suffix}`; }; -
Swivelgames created this gist
Nov 13, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ /* golf */ const toTwelveHour = time => { const [hr,min] = time.split(':'); return `${hr>12?hr-12:hr==0?12:hr}:${min}${hr>12?'PM':'AM'}`; } /* expanded utility */ const toTwelveHour = time => { let [hr,min] = time.split(':'); let suffix = 'AM'; if (hr == 0) { hr = 12; } else if (hr > 12) { hr -= 12; suffix = 'PM'; } return `${hr}:${min}${suffix}`; }