我知道有一个更好和正确的方法可以做到这一点,但我需要一个临时的解决方案。我需要增加额外的时间,这一天也会自动改变。我应该如何更改下面的代码?
package {
public class getTime {
private var today:Date=new Date();
private var hour:uint=today.getHours();
private var minute:uint=today.getMinutes();
private var month:uint=today.getMonth();
private var monthArray:Array=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
private var time:String = getUSClockTime(today.getHours(), today.getMinutes());
public var dateNtime:String=(time+", " +today.getDate()+" "+monthArray[month]+" "+today.getFullYear());;
public function getTime() {
}
private function getUSClockTime(hrs:uint, mins:uint):String {
var modifier:String="PM";
var minLabel:String=doubleDigitFormat(mins);
if (hrs>12) {
hrs=hrs-12;
} else if (hrs == 0) {
modifier="AM";
hrs=12;
} else if (hrs < 12) {
modifier="AM";
}
return (doubleDigitFormat(hrs) + ":" + minLabel + " " + modifier);
}
private function doubleDigitFormat(num):String {
if (num<10) {
return ("0" + num);
}
return num;
}
}
}