I was intrigued by the JavaScript peppered at the end of Basecamp website for the sign-off greeting:
Using the JavaScript Internationalization APIs, we can achieve this using the following steps:
- Determine the current date/time at browser location
- Determine the locale (combination of language and region) of the browser
- Combine it all - Voilà!
var dt = new Date();
console.log(dt);
var perLocale = navigator.language;
console.log(perLocale);
var daySpelt = new Intl.DateTimeFormat(perLocale, { weekday: "long" }).format(
dt
);
console.log("Enjoy the rest of your " + daySpelt + "!");