Last active
June 15, 2017 14:52
-
-
Save mimiflynn/bb334de27944fd511eb1 to your computer and use it in GitHub Desktop.
Fun little JS utils for life things
This file contains 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 characters
// Morning Afternoon or Evening? | |
const getGreetingTime = (m) => { | |
let g = null; | |
if (!m || !m.isValid()) { | |
return; // exit if not a moment object | |
} | |
let split_afternoon = 12 // 24hr time to split the afternoon | |
let split_evening = 17 // 24hr time to split the evening | |
let currentHour = parseFloat(m.format('HH')); | |
if ( currentHour >= split_afternoon && currentHour <= split_evening) { | |
g = 'afternoon'; | |
} else if (currentHour >= split_evening) { | |
g = 'evening'; | |
} else { | |
g = 'morning'; | |
} | |
return g; | |
} |
This file contains 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 characters
// get state code | |
"I've worked in TX and CA so far in my career.".match(/[A-Z]{2}/); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment