Skip to content

Instantly share code, notes, and snippets.

@SMoni
Last active December 23, 2015 09:29
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 SMoni/6614579 to your computer and use it in GitHub Desktop.
Save SMoni/6614579 to your computer and use it in GitHub Desktop.
... mit JavaScript."Die Berechnung erfolgt nach dem C++-Algorithmus von Ekkehard Hess aus einem Beitrag vom 29.7.1999 in der Newsgroup borland.public.cppbuilder.language (freigegeben zur allgemeinen Verwendung)"
var getWeek = function() {
var a = Math.floor((14 - (this.getMonth())) / 12);
var y = this.getYear() + 4800 - a;
var m = (this.getMonth()) + (12 * a) - 3;
var jd = this.getDate() - 2 + Math.floor(((153 * m) + 2) / 5) + (365 * y) + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400) - 32045;
^ Offset auf Montag
var d4 = (jd + 31741 - (jd % 7)) % 146097 % 36524 % 1461;
var L = Math.floor(d4 / 1460);
var d1 = ((d4 - L) % 365) + L;
return Math.floor(d1 / 7) + 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment