/*var startDate = new Date();
console.log(startDate);
var myDates = [];
// -1 because it operates on the actual date object!
for (var i = 0; i < 7; i++) {
var newDate = new Date(startDate.setDate(startDate.getDate() - 1));
myDates.push(newDate);
}
console.log(myDates);
*/
var fakeDate = new Date();
var actHour = fakeDate.getHours();
var year = fakeDate.getFullYear();
// month starts at 0
var month = fakeDate.getMonth();
var day = fakeDate.getDate();
var seconds = 0;
var milliseconds = 0;
// works
//var testDate = new Date(year, month, day, 17, 23, seconds, milliseconds);
//console.log(testDate);
var fakeDates = [];
var workers = [ "Denise", "Andy", "Bruno"];
for(var i = 0; i < 7; i++) {
// check in - start between 8 and 9 ó clock
var checkinHour = Math.round(Math.random() * 1 + 8);
var checkinMin = Math.round(Math.random() * 60);
var checkInDate = new Date(year, month, day, checkinHour, checkinMin, seconds, milliseconds);
checkInDate.setDate(checkInDate.getDate()-i);
fakeDates.push(checkInDate);
// check out - between 16 and 17 ó clock
var checkOutHour = Math.round(Math.random() * 1 + 16);
var checkOutMin = Math.round(Math.random() * 60);
var checkOutDate = new Date(year, month, day, checkOutHour, checkOutMin, seconds, milliseconds);
checkOutDate.setDate(checkOutDate.getDate()-i);
fakeDates.push(checkOutDate);
}
function WorkEntry(name, date, checkinout) {
this.name = name;
//this.date = new Date(date);
this.checkinout = checkinout;
}
var WorkEntries = {
entries: []
};
for(var i = 0; i < fakeDates.length; i++) {
var checkinoutVal = (i % 2 == 0) ? "checkin" : "checkout";
var workentry = new WorkEntry("Denise", fakeDates[i], checkinoutVal);
WorkEntries.entries.push(workentry);
}
console.log(WorkEntries);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.