0
我想在日期範圍內得到一個隨機日期,這是迄今爲止,但它似乎並沒有工作? 我在哪裏我錯了?如何選擇日期範圍內的隨機日期AS3
//Gets the date difference
private function differenceBetweenDates(date1:Date, date2:Date):Number{
var MS_PER_DAY:uint = 1000 * 60 * 60 * 24;
var tempDate:Date = new Date(date2.time - date1.time);
var difference:Number =
Math.abs(Math.round((tempDate.time/MS_PER_DAY)));
return difference; }
//得到一個隨機數 函數randomRange(最大:數字,分鐘:編號= 0):數{ 返回Math.round(的Math.random()*(最大 - 最小)+分鐘) ; }
protected function getRandomDate:void {
// TODO Auto-generated method stub
var dat1:Date= new Date();
var dat2:Date = new Date(1989, 4, 16)
var num:Number = new Number(differenceBetweenDates(dat2,dat1));
var random:Number= new Number(randomRange(num));
currDate.setDate(dat2.date+random);
getComic(formatDate(currDate));
dat2 = new Date(1989, 4, 16)
}