Skip to content

Instantly share code, notes, and snippets.

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 edcottrell/baa96bdeead3ff2bd49805cd0bd37822 to your computer and use it in GitHub Desktop.
Save edcottrell/baa96bdeead3ff2bd49805cd0bd37822 to your computer and use it in GitHub Desktop.
TextExpander Snippet for Yesterday's Julian Day Number
// This is useful for Google searches with date limitations.
// Based on the calculations at https://stackoverflow.com/a/11760121
Date.prototype.getJulian = function() {
return Math.floor((this / 86400000) - (this.getTimezoneOffset() / 1440) + 2440588);
}
var yesterday = new Date(); //set any date
yesterday.setDate(yesterday.getDate() - 1);
var julian = yesterday.getJulian(); //get Julian counterpart
TextExpander.appendOutput(julian);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment