Tests + Sugarpak

This commit is contained in:
rupert.avery
2013-11-30 21:48:36 +08:00
parent 4209e2c4c9
commit 3a39b10eb6
3 changed files with 343 additions and 22 deletions
+27 -22
View File
@@ -3,8 +3,8 @@
// Definitions by: David Khristepher Santos <http://github.com/rupertavery>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/** Defines a structure to be used in the add and set instance methods */
interface IDateJSConfig {
/** Defines a structure to be used in the add and set instance methods */
interface IDateJSLiteral {
milliseconds: number;
seconds: number;
minutes: number;
@@ -33,7 +33,7 @@ interface IDateJSStatic extends Date {
/** Returns a culture-specific timezone abbreviation based on a given offset and a boolean indicating whether daylight savings time is in effect. */
getTimezoneAbbreviation(timezoneOffset: number, isDayLightSavingsTime: boolean): string;
/** Gets the timezone offset if given a culture-specific string which is a valid full or abbreviated timezone name and a boolean indicating whether daylight savings time is in effect. */
getTimezoneOffset(timezoneAbbreviation?: string, isDayLightSavingsTime?: boolean): number
getTimezoneOffset(timezoneAbbreviation?: string, isDayLightSavingsTime?: boolean): number;
/** Converts the specified string value into its JavaScript Date equivalent using culture-specific format information. */
parse(dateString: string): IDateJS;
/** Converts the specified string value into its JavaScript Date equivalent using the specified format. The format of the string value must match one of the supplied formats exactly. */
@@ -43,23 +43,23 @@ interface IDateJSStatic extends Date {
/** Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth]. */
validateDay(day: number, fullYear: number, monthNumber: number): boolean;
/** Validates the number is within an acceptable range for hours[0 - 23].Returns true if within range, otherwise false. */
validateHour(hour: number): boolean
validateHour(hour: number): boolean;
/** Validates the number is within an acceptable range for milliseconds[0 - 999].Returns true if within range, otherwise false. */
validateMillisecond(milliseconds: number): boolean
validateMillisecond(milliseconds: number): boolean;
/** Validates the number is within an acceptable range for minutes[0 - 59].Returns true if within range, otherwise false. */
validateMinute(minutes: number): boolean
validateMinute(minutes: number): boolean;
/** Validates the number is within an acceptable range for months[0 - 11]. */
validateMonth(month: number): boolean
validateMonth(month: number): boolean;
/** Validates the number is within an acceptable range for seconds[0 - 59].Returns true if within range, otherwise false. */
validateSecond(second: number): boolean
validateSecond(second: number): boolean;
/** Validates the number is within an acceptable range for years[0 - 9999]. */
validateYear(year: number): boolean
validateYear(year: number): boolean;
}
/** DateJS Public Instance Methods */
interface IDateJS extends Date {
/** Adds(or subtracts) to the value of the year, month, day, hour, minute, second, millisecond of the date instance using given configuration object. Positive and Negative values allowed. */
add(config?: IDateJSConfig): IDateJS;
add(config?: IDateJSLiteral): IDateJS;
/** Adds the specified number of milliseconds to this instance. */
addMilliseconds(milliseconds: number): IDateJS;
/** Adds the specified number of seconds to this instance given the number of seconds to add.The number can be positive or negative. */
@@ -76,7 +76,7 @@ interface IDateJS extends Date {
addMonths(months: number): IDateJS;
/** Adds the specified number of years to this instance given the number of years to add.The number can be positive or negative. */
addYears(years: number): IDateJS;
/** Resets the time of this DateJS object to 12:00 AM(00:00), which is the start of the day. */
/** Resets the time of this Date object to 12:00 AM(00:00), which is the start of the day. */
clearTime(): IDateJS;
/** Resets the time of this Date object to the current time('now'). */
setTimeToNow(): IDateJS;
@@ -92,6 +92,10 @@ interface IDateJS extends Date {
isAfter(date: IDateJS): boolean;
/** Determines if this date occurs before the date to compare to. */
isBefore(date: IDateJS): boolean;
/** Determines if the current Date instance occurs on the same Date as the supplied 'date'. */
isToday(date: IDateJS): boolean;
/** Returns the number of milliseconds between this date and date. */
getElapsed(date: IDateJS): number;
/** Get the Ordinal day (numeric day number) of the year, adjusted for leap year. Returns 1 through 365 (366 in leap years) */
getOrdinalNumber(): number;
/** Get the timezone abbreviation of the current date. */
@@ -101,7 +105,7 @@ interface IDateJS extends Date {
/** Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week. */
getWeek(): number;
/** Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. */
getISOWeek(): string
getISOWeek(): string;
/** Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. */
setWeek(week: number): IDateJS;
/** Indicates whether Daylight Saving Time is observed in the current time zone. */
@@ -109,23 +113,24 @@ interface IDateJS extends Date {
/** Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. */
isDaylightSavingTime(): boolean;
/** Move to the next or previous dayOfWeek. Whether to move into the future (+1) or past(-1) is controlled by the optional direction parameter. */
moveToDayOfWeek(dayOfWeek: number, direction: number): IDateJS
moveToDayOfWeek(dayOfWeek: number, direction: number): IDateJS;
/** Moves the date to the first day of the month. */
moveToFirstDayOfMonth(): IDateJS
moveToFirstDayOfMonth(): IDateJS;
/** Moves the date to the last day of the month. */
moveToLastDayOfMonth(): IDateJS
moveToLastDayOfMonth(): IDateJS;
/** Move to the next or previous month.Whether to move into the future(+1) or past(-1) is controlled by the optional direction parameter. */
moveToMonth(month: number, direction: number): IDateJS
moveToMonth(month: number, direction: number): IDateJS;
/** Moves the date to the next nth occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. */
moveToNthOccurrence(dayOfWeek: number, occurrence: number): IDateJS
moveToNthOccurrence(dayOfWeek: number, occurrence: number): IDateJS;
/** Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. */
set(config: IDateJSConfig): IDateJS
set(config: IDateJSLiteral): IDateJS;
/** Set the timezone for the current date using a culture - specific timezone abbreviation("PST").Note that in most JavaScript implementations, this will appear to change the time since the timezone is always based on the locale. */
setTimezone(timezoneAbbreviation: string): IDateJS
setTimezone(timezoneAbbreviation: string): IDateJS;
/** Set the timezone for the current date using an offset(-0700).Note that in most JavaScript implementations, this will appear to change the time since the timezone is always based on the locale. */
setTimezoneOffset(timezoneOffset: number): IDateJS
setTimezoneOffset(timezoneOffset: number): IDateJS;
/** Converts the current date instance into a string with an ISO 8601 format.The date is converted to it's UTC value. As per the ISO 8601 specification, the string will be wrapped with double quotation marks ("). */
toISOString(): string
/** Converts the value of the current DateJS object to its equivalent string representation.Use format argument to specify format(optional).See FormatSpecifiers for more info. */
toISOString(): string;
/** Converts the value of the current Date object to its equivalent string representation.Use format argument to specify format(optional).See FormatSpecifiers for more info. */
toString(format?: string): string;
}