Created
May 20, 2016 07:06
-
-
Save stiekel/ba7efdb2b0c3545270f45ccdba06b437 to your computer and use it in GitHub Desktop.
JavaScript get previous work day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPrevWorkDay (t) { | |
if(!t) t = new Date(); | |
if( !(t instanceof Date) ) t = new Date(t); | |
var prevDay = new Date( t.getTime()); | |
do { | |
prevDay = new Date( prevDay.getTime() - 86400000 ); | |
} while( -1 !== [0, 6].indexOf(prevDay.getDay()) ); | |
return prevDay; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment