Or, more flexibly, you could write a JXA function which returned May 1 2018 from a variety of strings, including 2018-05-01
and simply today
:
(() => {
'use strict';
// mmmDyFromInformal :: String -> String
const mmmDyFromInformal = strDate => {
const fmtr = $.NSDateFormatter.alloc.init;
return (
fmtr.setLocale(
$.NSLocale.localeWithLocaleIdentifier('en_US_POSIX')
),
fmtr.setDateFormat('MMM d y'),
fmtr.stringFromDate(
$.NSDate.dateWithNaturalLanguageString(strDate)
).js
);
};
return [
mmmDyFromInformal('today'),
mmmDyFromInformal('2018-05-01'),
].join('\n');
})();