Packagecom.flexcalendar.components.calendar.utils
Classpublic class DateUtils
InheritanceDateUtils Inheritance Object

Helper class with static utils function for Date class



Public Methods
 MethodDefined By
  
Create DateUtils instance
DateUtils
  
addDays(date:Date, days:int):void
[static] Add selected amount of days to specified date
DateUtils
  
calculateDaySpan(start:Date, end:Date):int
[static] Calculate number of days that from start to end date.
DateUtils
  
calculateTimeSpan(start:Date, end:Date):Number
[static] Calculate number of milliseconds between 2 given dates
DateUtils
  
dateAfterDays(date:Date, days:int):Date
[static] Create new date with days added.
DateUtils
  
daysDifference(earlierDate:Date, laterDate:Date):Number
[static] Returns number of days between two dates If firstDate is the same day as secondDate, 0 is returned If earlierDate is one day before laterDate, 1 is returned If earlierDate is one day after laterDate, -1 is returned
DateUtils
  
daysInMonth(date:Date):int
[static] Get number of days in month
DateUtils
  
endOfDay(date:Date):Date
[static] Get end of specified day
DateUtils
  
endOfMonth(date:Date):Date
[static] Get end of specified month
DateUtils
  
endOfWeek(date:Date, firstDayOfWeek:int):Date
[static] Get end of specified week
DateUtils
  
endOfYear(date:Date):Date
[static] Get end of specified year
DateUtils
  
getYearDay(date:Date):int
[static] Get day number in specified year
DateUtils
  
getYearDayFromEnd(date:Date):int
[static] Get day number in specified year from end
DateUtils
  
intersect(dateRange1:DateRange, dateRange2:DateRange):DateRange
[static] Create intersection of two DateRanges
DateUtils
  
isLeapYear(date:Date):Boolean
[static] Determine if year is leap
DateUtils
  
periodsContaining(start1:Date, end1:Date, start2:Date, end2:Date):Boolean
[static] Determine if first period is contained inside of the second period True if: - start1-end1 period starts after start2, and ends before end2
DateUtils
  
periodsOverlapping(start1:Date, end1:Date, start2:Date, end2:Date):Boolean
[static] Determine if periods are overlapping.
DateUtils
  
setMonthDay(date:Date, dayNo:int):void
[static] Sets month day on provided date
DateUtils
  
setWeekDay(date:Date, day:int):void
[static] Set week day on the specified date
DateUtils
  
setYearDay(date:Date, dayNo:int):void
[static] Sets year day on provided date
DateUtils
  
setYearWeekNo(date:Date, weekNo:int, minDaysInFirstWeek:int, firstDayOfWeek:int):void
[static] Set week number in year
DateUtils
  
startOfDay(date:Date):Date
[static] Get start of specified day
DateUtils
  
startOfMonth(date:Date):Date
[static] Get start of specified month
DateUtils
  
startOfWeek(date:Date, firstDayOfWeek:int):Date
[static] Get start of specified week
DateUtils
  
startOfYear(date:Date):Date
[static] Get start of specified year
DateUtils
  
weekDayNumberToWeekDay(day:int):String
[static] Convert day number to week day string
DateUtils
  
weekDayToWeekDayNumber(day:String):int
[static] Convert string representing day in week to day number.
DateUtils
  
yearWeekNo(date:Date, minDaysInFirstWeek:int, firstDayOfWeek:int):int
[static] Determine week number in year.
DateUtils
Public Constants
 ConstantDefined By
  FR : String = FR
[static] FR (Friday)
DateUtils
  MILLI_IN_DAY : Number = 8.64E7
[static] Number of milliseconds in a day, 86400000 CAUTION: bare in mind that some days have 23 hours and some 25, because of daylight saving time
DateUtils
  MILLI_IN_HOUR : Number = 3600000.0
[static] Number of milliseconds in an hour, 3600000
DateUtils
  MILLI_IN_MINUTE : Number = 60000.0
[static] Number of milliseconds in a minute, 60000
DateUtils
  MILLI_IN_SECOND : Number = 1000
[static] Number of milliseconds in a second, 1000
DateUtils
  MILLI_IN_WEEK : Number = 6.048E8
[static] Number of milliseconds in a week, 604800000 CAUTION: bare in mind that some weeks can be one hour longer and some can be one hour shorter, because of daylight saving time
DateUtils
  MO : String = MO
[static] MO (Monday)
DateUtils
  SA : String = SA
[static] SA (Saturday)
DateUtils
  SU : String = SU
[static] SU (Sunday)
DateUtils
  TH : String = TH
[static] TH (Thursday)
DateUtils
  TU : String = TU
[static] TU (Tuesday)
DateUtils
  WE : String = WE
[static] WE (Wednesday)
DateUtils
Constructor Detail
DateUtils()Constructor
public function DateUtils()

Create DateUtils instance

Method Detail
addDays()method
public static function addDays(date:Date, days:int):void

Add selected amount of days to specified date

Parameters

date:Date — date to change
 
days:int — days to add (negative or positive value)

calculateDaySpan()method 
public static function calculateDaySpan(start:Date, end:Date):int

Calculate number of days that from start to end date. If event starts on day 01 and ends on 02, the result is 2

Parameters

start:Date
 
end:Date

Returns
int
calculateTimeSpan()method 
public static function calculateTimeSpan(start:Date, end:Date):Number

Calculate number of milliseconds between 2 given dates

Parameters

start:Date
 
end:Date

Returns
Number
dateAfterDays()method 
public static function dateAfterDays(date:Date, days:int):Date

Create new date with days added. Used addDays internally

Parameters

date:Date — base date
 
days:int — days to add

Returns
Date — new date after days
daysDifference()method 
public static function daysDifference(earlierDate:Date, laterDate:Date):Number

Returns number of days between two dates If firstDate is the same day as secondDate, 0 is returned If earlierDate is one day before laterDate, 1 is returned If earlierDate is one day after laterDate, -1 is returned

Parameters

earlierDate:Date — first date
 
laterDate:Date — second date

Returns
Number — difference between two dates
daysInMonth()method 
public static function daysInMonth(date:Date):int

Get number of days in month

Parameters

date:Date — Date containing the month. Leap years are handled with isLeapYear() function.

Returns
int — number of the days in requested month
endOfDay()method 
public static function endOfDay(date:Date):Date

Get end of specified day

Parameters

date:Date — Date representing requested day

Returns
Date — Date representing end of the requested day
endOfMonth()method 
public static function endOfMonth(date:Date):Date

Get end of specified month

Parameters

date:Date — Date representing requested month

Returns
Date — Date representing end of the requested month
endOfWeek()method 
public static function endOfWeek(date:Date, firstDayOfWeek:int):Date

Get end of specified week

Parameters

date:Date — Date representing requested week
 
firstDayOfWeek:int — number of the first day of the week - 0 for Sunday, 1 for Monday, and so on.

Returns
Date — Date representing end of the requested week
endOfYear()method 
public static function endOfYear(date:Date):Date

Get end of specified year

Parameters

date:Date — Date representing requested year

Returns
Date — Date representing end of the requested year
getYearDay()method 
public static function getYearDay(date:Date):int

Get day number in specified year

Parameters

date:Date — data containing requested day

Returns
int — day in year number
getYearDayFromEnd()method 
public static function getYearDayFromEnd(date:Date):int

Get day number in specified year from end

Parameters

date:Date — data containing requested day

Returns
int — day in year number from end
intersect()method 
public static function intersect(dateRange1:DateRange, dateRange2:DateRange):DateRange

Create intersection of two DateRanges

Parameters

dateRange1:DateRange — first DateRange
 
dateRange2:DateRange — second DateRange

Returns
DateRange — DateRange containing intersection period, or null if dates are not overlapping
isLeapYear()method 
public static function isLeapYear(date:Date):Boolean

Determine if year is leap

Parameters

date:Date — Date containing the year

Returns
Boolean — true if year is leap, false if it is not
periodsContaining()method 
public static function periodsContaining(start1:Date, end1:Date, start2:Date, end2:Date):Boolean

Determine if first period is contained inside of the second period True if: - start1-end1 period starts after start2, and ends before end2

Parameters

start1:Date — start of the first period
 
end1:Date — end of the first period
 
start2:Date — start of the second period
 
end2:Date — end of the second period

Returns
Boolean — true if periods are overlapping
periodsOverlapping()method 
public static function periodsOverlapping(start1:Date, end1:Date, start2:Date, end2:Date):Boolean

Determine if periods are overlapping. True if: - start1-end1 period starts before start2, but ends after it - start1-end1 period is inside start2-end2 period - start2-end2 period is inside start1-end1 period - start1-end1 period starts before end2, but ends after it

Parameters

start1:Date — start of the first period
 
end1:Date — end of the first period
 
start2:Date — start of the second period
 
end2:Date — end of the second period

Returns
Boolean — true if periods are overlapping
setMonthDay()method 
public static function setMonthDay(date:Date, dayNo:int):void

Sets month day on provided date

Parameters

date:Date — date to change
 
dayNo:int — day number in month, <-31, -1> or <1, 31> - if day is invalid for specified month, an error is thrown

setWeekDay()method 
public static function setWeekDay(date:Date, day:int):void

Set week day on the specified date

Parameters

date:Date — date to modify
 
day:int — day number (0 for Sunday, 1 for Monday and so on)

setYearDay()method 
public static function setYearDay(date:Date, dayNo:int):void

Sets year day on provided date

Parameters

date:Date — date to change
 
dayNo:int — day number, in <-366, -1> or <1, 366> - if day is invalid for specified year, an error is thrown

setYearWeekNo()method 
public static function setYearWeekNo(date:Date, weekNo:int, minDaysInFirstWeek:int, firstDayOfWeek:int):void

Set week number in year

Parameters

date:Date — date to modify
 
weekNo:int — requested week number
 
minDaysInFirstWeek:int — minimum number of days in the first week of the year. The value must be in the range 1 to 7.
 
firstDayOfWeek:int — number of the first day of the week - 0 for Sunday, 1 for Monday, and so on.

startOfDay()method 
public static function startOfDay(date:Date):Date

Get start of specified day

Parameters

date:Date — Date representing requested day

Returns
Date — Date representing beginning of the requested day
startOfMonth()method 
public static function startOfMonth(date:Date):Date

Get start of specified month

Parameters

date:Date — Date representing requested month

Returns
Date — Date representing start of the requested month
startOfWeek()method 
public static function startOfWeek(date:Date, firstDayOfWeek:int):Date

Get start of specified week

Parameters

date:Date — Date representing requested week
 
firstDayOfWeek:int — number of the first day of the week - 0 for Sunday, 1 for Monday, and so on.

Returns
Date — Date representing start of the requested week
startOfYear()method 
public static function startOfYear(date:Date):Date

Get start of specified year

Parameters

date:Date — Date representing requested year

Returns
Date — Date representing start of the requested year
weekDayNumberToWeekDay()method 
public static function weekDayNumberToWeekDay(day:int):String

Convert day number to week day string

Parameters

day:int — week day number, 0 for Sunday, 1 for Monday, and so on

Returns
String — one of SU MO TU WE TH FR SA, uppercase
weekDayToWeekDayNumber()method 
public static function weekDayToWeekDayNumber(day:String):int

Convert string representing day in week to day number. If invalid day is provided, an error is thrown.

Parameters

day:String — one of SU MO TU WE TH FR SA, case insensitive

Returns
int — 0 for Sunday, 1 for Monday, and so on
yearWeekNo()method 
public static function yearWeekNo(date:Date, minDaysInFirstWeek:int, firstDayOfWeek:int):int

Determine week number in year. During calculations, minDaysInFirstWeek property is used, Throws error if date is invalid (contains NaN values)

Parameters

date:Date — date to analyze
 
minDaysInFirstWeek:int — minimum number of days in the first week of the year. The value must be in the range 1 to 7.
 
firstDayOfWeek:int — number of the first day of the week - 0 for Sunday, 1 for Monday, and so on.

Returns
int — week number in year: -1 or 1-53
Constant Detail
FRConstant
public static const FR:String = FR

FR (Friday)

MILLI_IN_DAYConstant 
public static const MILLI_IN_DAY:Number = 8.64E7

Number of milliseconds in a day, 86400000 CAUTION: bare in mind that some days have 23 hours and some 25, because of daylight saving time

MILLI_IN_HOURConstant 
public static const MILLI_IN_HOUR:Number = 3600000.0

Number of milliseconds in an hour, 3600000

MILLI_IN_MINUTEConstant 
public static const MILLI_IN_MINUTE:Number = 60000.0

Number of milliseconds in a minute, 60000

MILLI_IN_SECONDConstant 
public static const MILLI_IN_SECOND:Number = 1000

Number of milliseconds in a second, 1000

MILLI_IN_WEEKConstant 
public static const MILLI_IN_WEEK:Number = 6.048E8

Number of milliseconds in a week, 604800000 CAUTION: bare in mind that some weeks can be one hour longer and some can be one hour shorter, because of daylight saving time

MOConstant 
public static const MO:String = MO

MO (Monday)

SAConstant 
public static const SA:String = SA

SA (Saturday)

SUConstant 
public static const SU:String = SU

SU (Sunday)

THConstant 
public static const TH:String = TH

TH (Thursday)

TUConstant 
public static const TU:String = TU

TU (Tuesday)

WEConstant 
public static const WE:String = WE

WE (Wednesday)