这里是我的功能,当时间偏移是圆形数字(1,2,3,4 ......)时它们可以正常工作,但是当它是3.5(3:30),4.5(4:30)它不起作用。 有人可以帮我这个:
private function init_vars():void
{
timeZoneOffset = FlexGlobals.topLevelApplication.parameters.clock_time_zone; // I load this with js
timeZoneOffset = 5,50; // just for test
}
private function tick(event:TimerEvent):void
{
var local: Date = new Date();
var utc: Date = new Date(local.getTime() + (local.getTimezoneOffset() * 60000));
var utcTime:Number=utc.getTime();
var new_offset_date:Number = utcTime + ((3600000) * timeZoneOffset);
var new_date:Date = new Date(new_offset_date);
currentTime = new Date(new_date);
showTime(currentTime); // another function just to display time
}
private function showTime(time:Date):void
{
seconds = time.getSeconds();
minutes= time.getMinutes();
hours= time.getHours();
//rotate
this.secondsPointer.rotation = (seconds * 6) - 90;
this.minutesPointer.rotation = (minutes * 6) - 90;
this.hoursPointer.rotation = (hours * 30) + (minutes * 0.5) - 90;
this.secondsPointer.visible = true;
this.minutesPointer.visible = true;
this.hoursPointer.visible = true;
}
答案 0 :(得分:1)
我运行了你的代码并且运行正常。我刚跟踪currentTime
,因为我没有showTime
函数,错误是否可能在该函数中?
如果可以,我建议尝试以下内容:
date.setUTCHours(date.getUTCHours() + hoursDifference); //5
date.setUTCMinutes(date.getUTCMinutes + minutesDifference); //30
使用时间修改日期(以毫秒为单位),具体取决于实际使用应用程序的方式/位置/时间,如果夏令时,可能会产生奇怪的错误。而且你不想处理每年只在世界某些国家发生过两次的错误。