forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetShortHour.as
More file actions
36 lines (35 loc) · 749 Bytes
/
getShortHour.as
File metadata and controls
36 lines (35 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package utils.date
{
/**
* Returns a short hour (0 - 12) represented by the specified date.
*
* If the hour is less than 12 (0 - 11 AM) then the hour will be returned.
*
* If the hour is greater than 12 (12 - 23 PM) then the hour minus 12
* will be returned.
*
* @param d1 The Date from which to generate the short hour
*
* @return An int between 0 and 13 ( 1 - 12 ) representing the short hour.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public function getShortHour(d:Date):int
{
var h:int = d.hours;
if (h == 0 || h == 12)
{
return 12;
}
else if (h > 12)
{
return h - 12;
}
else
{
return h;
}
}
}