Class $k.FlexTime
Represents a flexible date that allowes certain degrees of imprecision.A flextime attribute can restrict the degrees of imprecision. FlexTime has the following components, which can be set to an integer or undefined: year, month number, day number, hours, minutes.
- Defined in: FlexTime.js
Constructor Attributes | Constructor Name and Description |
---|---|
$k.FlexTime(value, month, day, hours, minutes)
Constructs a FlexTime from the argument(s), which can be a Date object, another FlexTime, undefined, or component values.
|
Method Summary
Class Detail
$k.FlexTime(value, month, day, hours, minutes)
Constructs a FlexTime from the argument(s), which can be a Date object, another FlexTime, undefined, or component values.
If undefined, all components of the returned FlexTime are undefined
// All components are undefined new $k.FlexTime(); // Current date new $k.FlexTime(new Date()); // 2007-06-03 21:48 new $k.FlexTime(2007, 6, 3, 21, 48);
- Parameters:
- value
- Date or FlexTime or year component
- month
- Month number
- day
- Day number
- hours
- Hours
- minutes
- Minutes
Method Detail
-
{boolean} coversDate(date)Returns true if the date is within the range of this flexible date
- Parameters:
- {date} date
- Returns:
- {boolean}
-
{boolean} equals(value)Returns true if the values are equal
- Parameters:
- value
- Returns:
- {boolean}
-
{number} getDayNumber()Returns the number of the day, e.g. 18 for 2011-03-18
- Returns:
- {number}
-
{number} getHours()Returns the hours
- Returns:
- {number}
-
{number} getMinutes()Returns the minutes
- Returns:
- {number}
-
{number} getMonthNumber()Returns the number of the month. Unlike Date.prototype.month(), this is not the 0-based month index, so for January getMonthNumber() returns 1, not 0
- Returns:
- {number}
-
{number} getYear()Returns the full year
- Returns:
- {number}
-
{Date} maxDate()Returns the latest exact date that is within the range of this flexible date, e.g. 2007-03-31 23:59:59 for the flexible date 2007-03
- Returns:
- {Date}
-
{Date} minDate()Returns the oldest exact date that is within the range of this flexible date, e.g. 2007-03-01 0:00:00 for the flexible date 2007-03
- Returns:
- {Date}
-
Parse the date string. Use the parse() method of an attribute value range if possible, because it can check the allowed formats
- Parameters:
- {string} string
- The string represantation of a FlexTime.
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidLanguage}
- If an invalid language was specified
- Returns:
- {$k.FlexTime} The parsed FlexTime
-
setDayNumber(day)Sets the number of the day, e.g. 23 for 2012-05-23
- Parameters:
- {number} day
-
setHours(hours)Sets the hours
- Parameters:
- {number} hours
-
setMinutes(minutes)Sets the minutes.
- Parameters:
- {number} minutes
-
setMonthNumber(month)Set the number of the month. Unlike Date.prototype.month(), this is not the 0-based month index, so for January pass 1 to setMonthNumber() , not 0.
- Parameters:
- {number} month
-
setValues(year, month, day, hours, minutes)Sets all components of the FlexTime
- Parameters:
- {number} year
- {number} month
- {number} day
- {number} hours
- {number} minutes
-
setYear(year)Sets the full year. The year is not modified, so setYear(99) sets the year 99, not 1999.
- Parameters:
- {number} year
-
{string} toString(language)Returns the string representation. Equivalent to valueString()
- Parameters:
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidLanguage}
- If an invalid language was specified
- Returns:
- {string}
-
{string} valueString(language)Returns the string representation
- Parameters:
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidLanguage}
- If an invalid language was specified
- Returns:
- {string}