Skip to content

Instantly share code, notes, and snippets.

View gusdewa's full-sized avatar
🎯
Focusing

Rahadian Dewandono gusdewa

🎯
Focusing
  • fita.co.id
  • Indonesia
  • 16:28 (UTC +07:00)
View GitHub Profile
@James1x0
James1x0 / momentjs.humanized.triplesplit.time.js
Created January 15, 2014 19:42
Get a humanized, "Morning", "Afternoon", "Evening" from moment.js **Great for user greetings!**
function getGreetingTime (m) {
var g = null; //return g
if(!m || !m.isValid()) { return; } //if we can't find a valid or filled moment, we return.
var split_afternoon = 12 //24hr time to split the afternoon
var split_evening = 17 //24hr time to split the evening
var currentHour = parseFloat(m.format("HH"));
if(currentHour >= split_afternoon && currentHour <= split_evening) {