Packagecom.keepcore.calendar.utils
Classpublic class CalendarDateUtils
InheritanceCalendarDateUtils Inheritance Object

Utility class for Date manipulation. Provides static methods to convert date to string and back. Provides static methods to make some date computations.



Public Properties
 PropertyDefined By
  FIRST_DAY_OF_WEEK : int = 1
[static] Defines the first day of week.
CalendarDateUtils
Public Methods
 MethodDefined By
  
compareDates(Date1:Date, Date2:Date, justDay:Boolean = false):int
[static] Compare 2 dates.
CalendarDateUtils
  
[static] Returns a time given in seconds in String with the following format "__:__"
CalendarDateUtils
  
convertTimeInSecondsToString(timeSeconds:Number, removeSeconds:Boolean = false):String
[static] Returns a time given in seconds in String with the following format "_h__mn__s" (more than 1h), "__mn__s" (more than 1mn) or "__s" (less than 1mn),
CalendarDateUtils
  
endOfWeek(date:Date):Date
[static] Returns the last day of the week.
CalendarDateUtils
  
EuropeanStringToDate(aString:String):Date
[static] Creates a Date object and initializes it using the passed string.
CalendarDateUtils
  
getCompleteDateTimeToString(date:Date):String
[static] Return complete date and time with seconds & milliseconds.
CalendarDateUtils
  
getDateDayIndex(date:Date):int
[static] Return the day index of a date according to the FIRST_DAY_OF_WEEK variable.
CalendarDateUtils
  
[static] Return date format string.
CalendarDateUtils
  
[static] Return date range string.
CalendarDateUtils
  
getDateToString(date:Date):String
[static] Return date string (without time).
CalendarDateUtils
  
getDayHeaderDateToString(date:Date, format:int):String
[static] Return date day string (number by default).
CalendarDateUtils
  
[static] Return day date string (string by default).
CalendarDateUtils
  
getDaysDifference(date1:Date, date2:Date):int
[static] Returns day count between 2 dates.
CalendarDateUtils
  
getFirstDayOfYear(date:Date):Date
[static]
CalendarDateUtils
  
[static] Return date formatted to european string ("D/MM/YYYY JJ:NN").
CalendarDateUtils
  
getFullDateAndTimeToString(date:Date):String
[static] Return full date & time string.
CalendarDateUtils
  
getFullDayMonthYearToString(date:Date):String
[static] Return full day, month & year string.
CalendarDateUtils
  
[static] Return day to string.
CalendarDateUtils
  
getFullYearToString(date:Date):String
[static] Return full year string.
CalendarDateUtils
  
getHourToString(date:Date):String
[static] Retour hour to string.
CalendarDateUtils
  
getLastDayOfMonth(date:Date):Date
[static] Return the last day of month.
CalendarDateUtils
  
getLastDayOfMonthDate(date:Date):int
[static] Return the last day of month date.
CalendarDateUtils
  
getMonthAndYearToString(date:Date):String
[static] Return date month & year to string.
CalendarDateUtils
  
getMonthCellDayToString(date:Date):String
[static] Return date day to string.
CalendarDateUtils
  
getNextMonthDate(date:Date):Date
[static] Return the next month date according to a given date.
CalendarDateUtils
  
getNextSameDateInMonth(date:Date):Date
[static] Returns the next same day date in month
CalendarDateUtils
  
getWeekNumber(date:Date):int
[static] Get date week number.
CalendarDateUtils
  
getYearMonthToString(date:Date):String
[static] Return date month to string.
CalendarDateUtils
  
isDayAfter(date1:Date, date2:Date):Boolean
[static] Returns if date1 day is after date2 day in time.
CalendarDateUtils
  
isDayBefore(date1:Date, date2:Date):Boolean
[static] Returns if date1 day is before date2 day in time.
CalendarDateUtils
  
isoToDate(value:String):Date
[static] Return date corresponding to given ISO string date (i.e: 2009-09-22T15:00:00.000Z).
CalendarDateUtils
  
isSameDate(date1:Date, date2:Date):Boolean
[static] Returns if 2 dates are the same (no reference comparison, only date & time).
CalendarDateUtils
  
isSameDay(date1:Date, date2:Date, checkSpecial:Boolean = false):Boolean
[static] Returns if 2 dates have the same day (no hours/min/sec/ms comparison)
CalendarDateUtils
  
isSameMonth(date1:Date, date2:Date):Boolean
[static] Returns if 2 dates have the same month (no date/hours/min/sec/ms comparison, only year & month)
CalendarDateUtils
  
isSpecialFullDayDate(date:Date):Boolean
[static] Returns if a date is set to 0h00
CalendarDateUtils
  
isTommorow(date1:Date, date2:Date):Boolean
[static] Returns if date1 is date2 tomorrow.
CalendarDateUtils
  
middleOfWeek(date:Date):Date
[static] Returns the middle day of the week (4th day in the week).
CalendarDateUtils
  
parseTime(value:String, guessAMPM:Boolean = false):Date
[static] Parse a time string and convert it to a Date (date part is always 01/01/2000).
CalendarDateUtils
  
[static] Sets seconds & milliseconds to 0 in a Date.
CalendarDateUtils
  
[static] Reset all formatters (called internally upon resourceChanged event) in order to apply locale formats.
CalendarDateUtils
  
startOfWeek(date:Date):Date
[static] Returns the first day of the week.
CalendarDateUtils
Public Constants
 ConstantDefined By
  DAY_DATE_LONG_FORMAT : int = 2
[static]
CalendarDateUtils
  DAY_DATE_MEDIUM_FORMAT : int = 1
[static]
CalendarDateUtils
  DAY_DATE_SHORT_FORMAT : int = 0
[static]
CalendarDateUtils
  FRIDAY : uint = 5
[static]
CalendarDateUtils
  MONDAY : uint = 1
[static]
CalendarDateUtils
  MS_BY_DAY : int = 8.64E7
[static]
CalendarDateUtils
  MS_BY_HOUR : int = 3600000.0
[static]
CalendarDateUtils
  MS_BY_MINUTES : int = 60000.0
[static]
CalendarDateUtils
  SATURDAY : uint = 6
[static]
CalendarDateUtils
  SUNDAY : uint = 0
[static]
CalendarDateUtils
  THURSDAY : uint = 4
[static]
CalendarDateUtils
  TUESDAY : uint = 2
[static]
CalendarDateUtils
  WEDNESDAY : uint = 3
[static]
CalendarDateUtils
Property Detail
FIRST_DAY_OF_WEEKproperty
public static var FIRST_DAY_OF_WEEK:int = 1

Defines the first day of week.

Method Detail
compareDates()method
public static function compareDates(Date1:Date, Date2:Date, justDay:Boolean = false):int

Compare 2 dates.

Parameters

Date1:Date — first date
 
Date2:Date — second date
 
justDay:Boolean (default = false) — indicates if only date are compared (no time comparison)

Returns
int
  • -1 if Date1 < Date2
  • 0 if Date1 == Date2 (date & time comparison, no reference comparison - only date comparison if justDay is true)
  • 1 if Date1 > Date2
  • convertTimeInSecondsToMinutesSecondsString()method 
    public static function convertTimeInSecondsToMinutesSecondsString(timeSeconds:Number):String

    Returns a time given in seconds in String with the following format "__:__"

    Parameters

    timeSeconds:Number — time in seconds

    Returns
    String — formatted string
    convertTimeInSecondsToString()method 
    public static function convertTimeInSecondsToString(timeSeconds:Number, removeSeconds:Boolean = false):String

    Returns a time given in seconds in String with the following format "_h__mn__s" (more than 1h), "__mn__s" (more than 1mn) or "__s" (less than 1mn),

    Parameters

    timeSeconds:Number — time in seconds
     
    removeSeconds:Boolean (default = false) — indicates if seconds have to be removed "_h__mn", "__mn" or nothing

    Returns
    String — formatted string
    endOfWeek()method 
    public static function endOfWeek(date:Date):Date

    Returns the last day of the week.

    Parameters

    date:Date

    Returns
    Date — last day of the week
    EuropeanStringToDate()method 
    public static function EuropeanStringToDate(aString:String):Date

    Creates a Date object and initializes it using the passed string. The expected format is DD/MM/YYYY (no time) or DD/MM/YYYY HH:NN:SS Numbers can have less than 2 digits NOTE: has to be reviewed as it is locale dependent (european date format)

    Parameters

    aString:String — String representation of the date

    Returns
    Date — Date object, or null if an error occurs
    getCompleteDateTimeToString()method 
    public static function getCompleteDateTimeToString(date:Date):String

    Return complete date and time with seconds & milliseconds. Date formats is:

    Hour format is: Seconds and milliseconds are displayed using "SSs QQQ" format.

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getDateDayIndex()method 
    public static function getDateDayIndex(date:Date):int

    Return the day index of a date according to the FIRST_DAY_OF_WEEK variable. This index corresponds to the month/week column of the day.

    Parameters

    date:Date — date to analyze

    Returns
    int — the day index (0 for the first day, 6 for the last one)
    getDateFormatString()method 
    public static function getDateFormatString():String

    Return date format string. Date format is:

    Returns
    String — date format string
    getDateRangeToString()method 
    public static function getDateRangeToString(range:DateRange):String

    Return date range string. This string is used in control bar date label in week view. Date format is:

    Parameters

    range:DateRange — date range format

    Returns
    String — formatted string
    getDateToString()method 
    public static function getDateToString(date:Date):String

    Return date string (without time). Date format is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getDayHeaderDateToString()method 
    public static function getDayHeaderDateToString(date:Date, format:int):String

    Return date day string (number by default). This string is used in day headers of day/week/month views. By default, short format is used for all days except first & last day of months, first & last days of week in week view, day in day view that use medium format. But if displayMonthNamesInAllDays property is set to true medium format is used for all days. Long format is used for first & last days of years. Short format is:

    Medium format is: Long format is:

    Parameters

    date:Date — date to format
     
    format:int (default = NaN) — indicates which format should be used (available values are DAY_DATE_SHORT_FORMAT, DAY_DATE_MEDIUM_FORMAT & DAY_DATE_LONG_FORMAT).

    Returns
    String — formatted string
    getDayHeaderDayToStringByDayNumber()method 
    public static function getDayHeaderDayToStringByDayNumber(day:int):String

    Return day date string (string by default). This string is used in day headers of day/week/month views. String are:

    Parameters

    day:int — day number (0 is Sunday)

    Returns
    String — formatted string
    getDaysDifference()method 
    public static function getDaysDifference(date1:Date, date2:Date):int

    Returns day count between 2 dates. Only dates are taken in account (not hours, minutes...). i.e: getDaysDifference(3 March, 5 March) returns - 2

    Parameters

    date1:Date — first date
     
    date2:Date — second date

    Returns
    int — days count difference
    getFirstDayOfYear()method 
    public static function getFirstDayOfYear(date:Date):Date

    Parameters

    date:Date

    Returns
    Date
    getFullDateAndTimeToEuropeanString()method 
    public static function getFullDateAndTimeToEuropeanString(date:Date):String

    Return date formatted to european string ("D/MM/YYYY JJ:NN").

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getFullDateAndTimeToString()method 
    public static function getFullDateAndTimeToString(date:Date):String

    Return full date & time string. This string is used in default item renderer tooltip to format dates. Date formats is:

    Hour format is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getFullDayMonthYearToString()method 
    public static function getFullDayMonthYearToString(date:Date):String

    Return full day, month & year string. This string is used in control bar date label in day view and in default mouse selection tooltip. Date formats is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getFullDayToStringByDayNumber()method 
    public static function getFullDayToStringByDayNumber(day:int):String

    Return day to string. This string (first letter) is used for KCMiniCalendar component to display days letters in column headers and, by default, for day cell headers. Strings correspond to dayNames properties in SharedResources bundle.

    Parameters

    day:int — day number (0 is Sunday)

    Returns
    String — formatted string
    getFullYearToString()method 
    public static function getFullYearToString(date:Date):String

    Return full year string. This string is used in control bar date label in year view. Date formats is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getHourToString()method 
    public static function getHourToString(date:Date):String

    Retour hour to string. This string is used in day and week views hour grid, default renderer hours labels, & mouse selection default tooltip.

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getLastDayOfMonth()method 
    public static function getLastDayOfMonth(date:Date):Date

    Return the last day of month.

    Parameters

    date:Date — date in a month.

    Returns
    Date — last day of month.
    getLastDayOfMonthDate()method 
    public static function getLastDayOfMonthDate(date:Date):int

    Return the last day of month date.

    Parameters

    date:Date — date in a month.

    Returns
    int — last day of month date.
    getMonthAndYearToString()method 
    public static function getMonthAndYearToString(date:Date):String

    Return date month & year to string. This string is used for control bar label in month view and for KCMiniCalendar component to display current month label. Date formats is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getMonthCellDayToString()method 
    public static function getMonthCellDayToString(date:Date):String

    Return date day to string. This string is used for days labels in year view. Date formats is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    getNextMonthDate()method 
    public static function getNextMonthDate(date:Date):Date

    Return the next month date according to a given date. Note that if next month has too less days, the last day of next month will be returned (i.e: 28th of February for 29th/30th/31st of January).

    Parameters

    date:Date — date in a month.

    Returns
    Date — last day of month date.
    getNextSameDateInMonth()method 
    public static function getNextSameDateInMonth(date:Date):Date

    Returns the next same day date in month

    Parameters

    date:Date — : current date

    Returns
    Date — null if the next same day date is not in the same month
    getWeekNumber()method 
    public static function getWeekNumber(date:Date):int

    Get date week number.

    Parameters

    date:Date

    Returns
    int — week number.
    getYearMonthToString()method 
    public static function getYearMonthToString(date:Date):String

    Return date month to string. This string is used for month header labels in year view & for KCMiniCalendar component months combobox. Date formats is:

    Parameters

    date:Date — date to format

    Returns
    String — formatted string
    isDayAfter()method 
    public static function isDayAfter(date1:Date, date2:Date):Boolean

    Returns if date1 day is after date2 day in time.

    Parameters

    date1:Date — date to check against date2
     
    date2:Date — date to check against date1

    Returns
    Boolean — true if date1 is prior to date2 (false if days are the same)
    isDayBefore()method 
    public static function isDayBefore(date1:Date, date2:Date):Boolean

    Returns if date1 day is before date2 day in time.

    Parameters

    date1:Date — date to check against date2
     
    date2:Date — date to check against date1

    Returns
    Boolean — true if date1 is prior to date2 (false if days are the same)
    isoToDate()method 
    public static function isoToDate(value:String):Date

    Return date corresponding to given ISO string date (i.e: 2009-09-22T15:00:00.000Z).

    Parameters

    value:String — ISO string date

    Returns
    Date — date
    isSameDate()method 
    public static function isSameDate(date1:Date, date2:Date):Boolean

    Returns if 2 dates are the same (no reference comparison, only date & time). Note: dates can be null.

    Parameters

    date1:Date — first date
     
    date2:Date — second date

    Returns
    Boolean — true if dates are the same
    isSameDay()method 
    public static function isSameDay(date1:Date, date2:Date, checkSpecial:Boolean = false):Boolean

    Returns if 2 dates have the same day (no hours/min/sec/ms comparison)

    Parameters

    date1:Date — first date
     
    date2:Date — second date
     
    checkSpecial:Boolean (default = false) — indicates if full day special test should be done

    Returns
    Boolean — true if days are the same Important note: special full day event are described with a end date set at day+1 but with 00:00 as hour/minutes So if checkSpecial is set to true xx/yy will be considered as same day as xx+1/y 00:00
    isSameMonth()method 
    public static function isSameMonth(date1:Date, date2:Date):Boolean

    Returns if 2 dates have the same month (no date/hours/min/sec/ms comparison, only year & month)

    Parameters

    date1:Date — first date
     
    date2:Date — second date

    Returns
    Boolean — true if months are the same
    isSpecialFullDayDate()method 
    public static function isSpecialFullDayDate(date:Date):Boolean

    Returns if a date is set to 0h00

    Parameters

    date:Date — date to test

    Returns
    Boolean — true if date is a special full day end date
    isTommorow()method 
    public static function isTommorow(date1:Date, date2:Date):Boolean

    Returns if date1 is date2 tomorrow.

    Parameters

    date1:Date — date to check against date2
     
    date2:Date — date to check against date1

    Returns
    Boolean — true if date1 is date2 tomorrow
    middleOfWeek()method 
    public static function middleOfWeek(date:Date):Date

    Returns the middle day of the week (4th day in the week).

    Parameters

    date:Date

    Returns
    Date — last day of the week
    parseTime()method 
    public static function parseTime(value:String, guessAMPM:Boolean = false):Date

    Parse a time string and convert it to a Date (date part is always 01/01/2000).

    Parameters

    value:String — time in string
     
    guessAMPM:Boolean (default = false) — if time detected is less or equal to 6, returned time value is PM.

    Returns
    Date — time as Date
    removeSecondsAndMilliseconds()method 
    public static function removeSecondsAndMilliseconds(value:Date):void

    Sets seconds & milliseconds to 0 in a Date.

    Parameters

    value:Date — date to change.

    resetFormatters()method 
    public static function resetFormatters():void

    Reset all formatters (called internally upon resourceChanged event) in order to apply locale formats.

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

    Returns the first day of the week.

    Parameters

    date:Date

    Returns
    Date — first day of the week
    Constant Detail
    DAY_DATE_LONG_FORMATConstant
    public static const DAY_DATE_LONG_FORMAT:int = 2

    DAY_DATE_MEDIUM_FORMATConstant 
    public static const DAY_DATE_MEDIUM_FORMAT:int = 1

    DAY_DATE_SHORT_FORMATConstant 
    public static const DAY_DATE_SHORT_FORMAT:int = 0

    FRIDAYConstant 
    public static const FRIDAY:uint = 5

    MONDAYConstant 
    public static const MONDAY:uint = 1

    MS_BY_DAYConstant 
    public static const MS_BY_DAY:int = 8.64E7

    MS_BY_HOURConstant 
    public static const MS_BY_HOUR:int = 3600000.0

    MS_BY_MINUTESConstant 
    public static const MS_BY_MINUTES:int = 60000.0

    SATURDAYConstant 
    public static const SATURDAY:uint = 6

    SUNDAYConstant 
    public static const SUNDAY:uint = 0

    THURSDAYConstant 
    public static const THURSDAY:uint = 4

    TUESDAYConstant 
    public static const TUESDAY:uint = 2

    WEDNESDAYConstant 
    public static const WEDNESDAY:uint = 3