Last active
August 29, 2015 14:23
-
-
Save EeroHeroHeino/f57372c0945838b2149d to your computer and use it in GitHub Desktop.
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
// randomize Date, and then add second Date which is 6 hours and 30 minutes later | |
var date = new Date(); | |
var days_in_future = 50; | |
var add_minutes = 30; | |
var add_hours = 6; | |
date.setDate(date.getDate() + parseInt(Math.random() * days_in_future)); | |
date.setHours(parseInt(Math.random() * 24)); | |
date.setMinutes(parseInt(Math.random() * 60)); | |
function td(number) { return (number < 10 ? '0' : '') + number;} | |
function frmt_day(date) { return date.getDate() + '.' + (date.getMonth() + 1) + '.' + date.getFullYear()); } | |
function frmt_hour(date) { return td(date.getHours()) + ':' + td(date.getMinutes())); } | |
var second_date = new Date(date.getTime() + 1000 * 60 * (add_minutes + add_hours * 60)); | |
var hourInputs = document.querySelectorAll(".ui-timepicker-container > input"); | |
var dayInput = document.querySelector("input.hasDatepicker"); | |
dayInput.value = frmt_day(date); | |
hourInputs[0].value = frmt_hour(date); | |
hourInputs[1].value = frmt_hour(second_date); | |
callback(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment