Skip to content

Instantly share code, notes, and snippets.

@teddy-dev
Last active August 20, 2020 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teddy-dev/13d0ae692e86b500504c00e28edcfb01 to your computer and use it in GitHub Desktop.
Save teddy-dev/13d0ae692e86b500504c00e28edcfb01 to your computer and use it in GitHub Desktop.
Wallpaper Engine: Display Date
'use strict';
export function update(value) {
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let time = new Date();
return `${months[time.getMonth()]} ${getOrdinalNum(time.getDate())}, ${time.getFullYear()}`;
}
// public domain
function getOrdinalNum(n) {
return n + (n > 0 ? ['th', 'st', 'nd', 'rd'][(n > 3 && n < 21) || n % 10 > 3 ? 0 : n % 10] : '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment