Changed default time format to AMPM
This commit is contained in:
parent
7e8baad86a
commit
9a9b619e7c
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
package com.sqwiggle {
public class Utils {
public function Utils() {
// constructor code
}
static public function getFormattedTime(twelveHour:Boolean = false):String {
// create time segments
var theDate = new Date();
var seconds = theDate.getSeconds();
var minutes = theDate.getMinutes();
var hours = theDate.getHours();
var ampm = '';
// create vars for sec and min
var min:String = minutes.toString();
// zero pad
min = (min.length == 1) ? '0' + minutes.toString() : min;
// convert to am/pm if we need to
if (twelveHour) {
ampm = (hours >= 12) ? 'pm' : 'am';
hours = (hours >= 13) ? hours - 12 : hours;
}
// set time string
return hours +':'+ min +' '+ ampm;
}
}
}
|
||||
package com.sqwiggle {
public class Utils {
public function Utils() {
// constructor code
}
static public function getFormattedTime(twelveHour:Boolean = true):String {
// create time segments
var theDate = new Date();
var seconds = theDate.getSeconds();
var minutes = theDate.getMinutes();
var hours = theDate.getHours();
var ampm = '';
// create vars for sec and min
var min:String = minutes.toString();
// zero pad
min = (min.length == 1) ? '0' + minutes.toString() : min;
// convert to am/pm if we need to
if (twelveHour) {
ampm = (hours >= 12) ? 'PM' : 'AM';
hours = (hours >= 13) ? hours - 12 : hours;
}
// set time string
return hours +':'+ min +' '+ ampm;
}
}
}
|
Loading…
Reference in New Issue
Block a user