Add typings for version 1.5.1

This commit is contained in:
Rogier Schouten
2014-08-20 13:17:24 +02:00
parent c10b6a363d
commit fd019eed8b
4 changed files with 1331 additions and 9 deletions

View File

@@ -0,0 +1,183 @@
/// <reference path="timezonecomplete-1.4.6.d.ts" />
import tc = require("timezonecomplete-1.4.6");
var b: boolean;
var n: number;
var s: string;
var w: tc.WeekDay;
b = tc.isLeapYear(2014);
n = tc.daysInMonth(2014, 10);
n = tc.daysInYear(2014);
n = tc.dayOfYear(2014, 1, 2);
w = tc.lastWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday);
n = tc.weekDayOnOrAfter(2014, 1, 14, tc.WeekDay.Monday);
n = tc.weekDayOnOrBefore(2014, 1, 14, tc.WeekDay.Monday);
// DURATION
var d: tc.Duration;
var d1: tc.Duration = tc.Duration.hours(24);
var d2: tc.Duration = tc.Duration.minutes(24);
var d3: tc.Duration = tc.Duration.seconds(24);
var d4: tc.Duration = tc.Duration.milliseconds(24);
var d5: tc.Duration = new tc.Duration(24);
var d6: tc.Duration = new tc.Duration("00:01");
var d7: tc.Duration = d6.clone();
n = d7.wholeHours();
n = d7.hours();
n = d7.minutes();
n = d7.minute();
n = d7.seconds();
n = d7.second();
n = d7.milliseconds();
n = d7.millisecond();
s = d7.sign();
b = d7.lessThan(d6);
b = d7.greaterThan(d6);
d = d7.min(d6);
d = d7.max(d6);
d = d7.multiply(3);
d = d7.divide(0.3);
d = d7.add(d6);
d = d7.sub(d6);
s = d7.toString();
// TIMEZONE
var t: tc.TimeZone;
var k: tc.TimeZoneKind;
t = tc.TimeZone.local();
t = tc.TimeZone.utc();
t = tc.TimeZone.zone(2);
t = tc.TimeZone.zone("+01:00");
s = t.name();
k = t.kind();
b = t.equals(t);
b = t.isUtc();
n = t.offsetForUtc(2014, 1, 1, 13, 0, 5, 123);
n = t.offsetForZone(2014, 1, 1, 13, 0, 5, 123);
n = t.offsetForUtcDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.Get);
n = t.offsetForZoneDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.GetUTC);
s = t.toString();
s = tc.TimeZone.offsetToString(2);
n = tc.TimeZone.stringToOffset("+00:01");
// REALTIMESOURCE
var date: Date = (new tc.RealTimeSource()).now();
// DATETIME
var dt: tc.DateTime;
var ts: tc.TimeSource = tc.DateTime.timeSource;
dt = tc.DateTime.nowLocal();
dt = tc.DateTime.nowUtc();
dt = tc.DateTime.now(tc.TimeZone.local());
dt = new tc.DateTime();
dt = new tc.DateTime("2014-01-01T13:05:01.123 UTC");
dt = new tc.DateTime("2014-01-01T13:05:01.123", tc.TimeZone.utc());
dt = new tc.DateTime(date, tc.DateFunctions.Get);
dt = new tc.DateTime(date, tc.DateFunctions.Get, tc.TimeZone.utc());
dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123);
dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123, tc.TimeZone.utc());
dt = new tc.DateTime(89949284);
dt = new tc.DateTime(89949284, tc.TimeZone.utc());
dt = dt.clone();
t = dt.zone();
n = dt.offset();
n = dt.year();
n = dt.month();
n = dt.day();
n = dt.hour();
n = dt.minute();
n = dt.second();
n = dt.millisecond();
n = dt.unixUtcMillis();
n = dt.utcYear();
n = dt.utcMonth();
n = dt.utcDay();
n = dt.utcHour();
n = dt.utcMinute();
n = dt.utcSecond();
n = dt.utcMillisecond();
dt.convert(tc.TimeZone.local());
dt = dt.toZone(tc.TimeZone.utc());
date = dt.toDate();
dt = dt.add(tc.Duration.seconds(2));
dt = dt.add(2, tc.TimeUnit.Year);
dt = dt.add(2, tc.TimeUnit.Month);
dt = dt.add(2, tc.TimeUnit.Week);
dt = dt.add(2, tc.TimeUnit.Day);
dt = dt.add(2, tc.TimeUnit.Hour);
dt = dt.add(2, tc.TimeUnit.Minute);
dt = dt.add(2, tc.TimeUnit.Second);
dt = dt.addLocal(2, tc.TimeUnit.Second);
dt = dt.sub(tc.Duration.seconds(2));
dt = dt.sub(2, tc.TimeUnit.Year);
dt = dt.sub(2, tc.TimeUnit.Month);
dt = dt.sub(2, tc.TimeUnit.Week);
dt = dt.sub(2, tc.TimeUnit.Day);
dt = dt.sub(2, tc.TimeUnit.Hour);
dt = dt.sub(2, tc.TimeUnit.Minute);
dt = dt.sub(2, tc.TimeUnit.Second);
dt = dt.subLocal(2, tc.TimeUnit.Second);
d = dt.diff(new tc.DateTime(9289234, tc.TimeZone.local()));
b = dt.lessThan(new tc.DateTime(9289234, tc.TimeZone.local()));
b = dt.lessEqual(new tc.DateTime(9289234, tc.TimeZone.local()));
b = dt.greaterThan(new tc.DateTime(9289234, tc.TimeZone.local()));
b = dt.greaterEqual(new tc.DateTime(9289234, tc.TimeZone.local()));
s = dt.toIsoString();
s = dt.toString();
s = dt.toUtcString();
var wd: tc.WeekDay;
wd = dt.weekDay();
wd = dt.utcWeekDay();
// PERIOD
s = tc.periodDstToString(tc.PeriodDst.RegularIntervals);
s = tc.periodDstToString(tc.PeriodDst.RegularLocalTime);
var p: tc.Period;
p = new tc.Period(tc.DateTime.nowLocal(), 1, tc.TimeUnit.Hour, tc.PeriodDst.RegularLocalTime);
dt = p.start();
n = p.amount();
var tu: tc.TimeUnit = p.unit();
var pd: tc.PeriodDst = p.dst();
dt = p.findFirst(tc.DateTime.nowLocal());
dt = p.findNext(dt);
s = p.toIsoString();
s = p.toString();

File diff suppressed because it is too large Load Diff

View File

@@ -11,9 +11,12 @@ b = tc.isLeapYear(2014);
n = tc.daysInMonth(2014, 10);
n = tc.daysInYear(2014);
n = tc.dayOfYear(2014, 1, 2);
w = tc.firstWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday);
w = tc.lastWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday);
n = tc.weekDayOnOrAfter(2014, 1, 14, tc.WeekDay.Monday);
n = tc.weekDayOnOrBefore(2014, 1, 14, tc.WeekDay.Monday);
n = tc.secondOfDay(13, 59, 59);
n = tc.weekOfMonth(2014, 1, 1);
// DURATION
@@ -97,6 +100,10 @@ n = dt.day();
n = dt.hour();
n = dt.minute();
n = dt.second();
n = dt.weekNumber();
n = dt.weekOfMonth();
n = dt.secondOfDay();
n = dt.dayOfYear();
n = dt.millisecond();
n = dt.unixUtcMillis();
n = dt.utcYear();
@@ -106,6 +113,11 @@ n = dt.utcHour();
n = dt.utcMinute();
n = dt.utcSecond();
n = dt.utcMillisecond();
n = dt.utcWeekNumber();
n = dt.utcWeekOfMonth();
n = dt.utcSecondOfDay();
n = dt.utcDayOfYear();
s = dt.format("%Y-%m-%d");
dt.convert(tc.TimeZone.local());
dt = dt.toZone(tc.TimeZone.utc());
date = dt.toDate();

View File

@@ -1,4 +1,4 @@
// Type definitions for timezonecomplete 1.4.6
// Type definitions for timezonecomplete 1.5.1
// Project: https://github.com/SpiritIT/timezonecomplete
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -11,10 +11,14 @@ declare module 'timezonecomplete' {
export import isLeapYear = basics.isLeapYear;
export import daysInMonth = basics.daysInMonth;
export import daysInYear = basics.daysInYear;
export import dayOfYear = basics.dayOfYear;
export import firstWeekDayOfMonth = basics.firstWeekDayOfMonth;
export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth;
export import weekDayOnOrAfter = basics.weekDayOnOrAfter;
export import weekDayOnOrBefore = basics.weekDayOnOrBefore;
export import weekNumber = basics.weekNumber;
export import weekOfMonth = basics.weekOfMonth;
export import dayOfYear = basics.dayOfYear;
export import secondOfDay = basics.secondOfDay;
import datetime = require("__timezonecomplete/datetime");
export import DateTime = datetime.DateTime;
import duration = require("__timezonecomplete/duration");
@@ -93,6 +97,16 @@ declare module '__timezonecomplete/basics' {
* @return the last occurrence of the week day in the month
*/
export function lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number;
/**
* Returns the first instance of the given weekday in the given month
*
* @param year The year
* @param month the month 1-12
* @param weekDay the desired week day
*
* @return the first occurrence of the week day in the month
*/
export function firstWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number;
/**
* Returns the day-of-month that is on the given weekday and which is >= the given day.
* Throws if the month has no such day.
@@ -103,6 +117,19 @@ declare module '__timezonecomplete/basics' {
* Throws if the month has no such day.
*/
export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number;
export function weekOfMonth(year: number, month: number, day: number): number;
/**
* The ISO 8601 week number for the given date. Week 1 is the week
* that has January 4th in it, and it starts on Monday.
* See https://en.wikipedia.org/wiki/ISO_week_date
*
* @param year Year e.g. 1988
* @param month Month 1-12
* @param day Day of month 1-31
*
* @return Week number 1-53
*/
export function weekNumber(year: number, month: number, day: number): number;
/**
* Convert a unix milli timestamp into a TimeT structure.
* This does NOT take leap seconds into account.
@@ -131,6 +158,10 @@ declare module '__timezonecomplete/basics' {
* This does NOT take leap seconds into account.
*/
export function weekDayNoLeapSecs(unixMillis: number): WeekDay;
/**
* N-th second in the day, counting from 0
*/
export function secondOfDay(hour: number, minute: number, second: number): number;
/**
* Basic representation of a date and time
*/
@@ -332,6 +363,12 @@ declare module '__timezonecomplete/datetime' {
* @return The time zone that the date is in. May be null for unaware dates.
*/
zone(): timezone.TimeZone;
/**
* Zone name abbreviation at this time
* @param dstDependent (default true) set to false for a DST-agnostic abbreviation
* @return The abbreviation
*/
zoneAbbreviation(dstDependent?: boolean): string;
/**
* @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates.
*/
@@ -369,6 +406,36 @@ declare module '__timezonecomplete/datetime' {
* week day numbers)
*/
weekDay(): basics.WeekDay;
/**
* Returns the day number within the year: Jan 1st has number 0,
* Jan 2nd has number 1 etc.
*
* @return the day-of-year [0-366]
*/
dayOfYear(): number;
/**
* The ISO 8601 week number. Week 1 is the week
* that has January 4th in it, and it starts on Monday.
* See https://en.wikipedia.org/wiki/ISO_week_date
*
* @return Week number [1-53]
*/
weekNumber(): number;
/**
* The week of this month. There is no official standard for this,
* but we assume the same rules for the weekNumber (i.e.
* week 1 is the week that has the 4th day of the month in it)
*
* @return Week number [1-5]
*/
weekOfMonth(): number;
/**
* Returns the number of seconds that have passed on the current day
* Does not consider leap seconds
*
* @return seconds [0-86399]
*/
secondOfDay(): number;
/**
* @return Milliseconds since 1970-01-01T00:00:00.000Z
*/
@@ -397,6 +464,13 @@ declare module '__timezonecomplete/datetime' {
* @return The UTC seconds 0-59
*/
utcSecond(): number;
/**
* Returns the UTC day number within the year: Jan 1st has number 0,
* Jan 2nd has number 1 etc.
*
* @return the day-of-year [0-366]
*/
utcDayOfYear(): number;
/**
* @return The UTC milliseconds 0-999
*/
@@ -406,6 +480,29 @@ declare module '__timezonecomplete/datetime' {
* week day numbers)
*/
utcWeekDay(): basics.WeekDay;
/**
* The ISO 8601 UTC week number. Week 1 is the week
* that has January 4th in it, and it starts on Monday.
* See https://en.wikipedia.org/wiki/ISO_week_date
*
* @return Week number [1-53]
*/
utcWeekNumber(): number;
/**
* The week of this month. There is no official standard for this,
* but we assume the same rules for the weekNumber (i.e.
* week 1 is the week that has the 4th day of the month in it)
*
* @return Week number [1-5]
*/
utcWeekOfMonth(): number;
/**
* Returns the number of seconds that have passed on the current day
* Does not consider leap seconds
*
* @return seconds [0-86399]
*/
utcSecondOfDay(): number;
/**
* Convert this date to the given time zone (in-place).
* Throws if this date does not have a time zone.
@@ -514,6 +611,7 @@ declare module '__timezonecomplete/datetime' {
* E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam
*/
toIsoString(): string;
format(formatString: string): string;
/**
* Modified ISO 8601 format string with IANA name if applicable.
* E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam"
@@ -523,6 +621,10 @@ declare module '__timezonecomplete/datetime' {
* Used by util.inspect()
*/
inspect(): string;
/**
* The valueOf() method returns the primitive value of the specified object.
*/
valueOf(): any;
/**
* Modified ISO 8601 format string in UTC without time zone info
*/
@@ -678,6 +780,10 @@ declare module '__timezonecomplete/duration' {
* Used by util.inspect()
*/
inspect(): string;
/**
* The valueOf() method returns the primitive value of the specified object.
*/
valueOf(): any;
}
}
@@ -923,13 +1029,15 @@ declare module '__timezonecomplete/timezone' {
hasDst(): boolean;
/**
* Calculate timezone offset from a UTC time.
* @param year local full year
* @param month local month 1-12 (note this deviates from JavaScript date)
* @param day local day of month 1-31
* @param hour local hour 0-23
* @param minute local minute 0-59
* @param second local second 0-59
* @param millisecond local millisecond 0-999
*
* @param year Full year
* @param month Month 1-12 (note this deviates from JavaScript date)
* @param day Day of month 1-31
* @param hour Hour 0-23
* @param minute Minute 0-59
* @param second Second 0-59
* @param millisecond Millisecond 0-999
*
* @return the offset of this time zone with respect to UTC at the given time, in minutes.
*/
offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
@@ -965,6 +1073,21 @@ declare module '__timezonecomplete/timezone' {
* @param funcs: the set of functions to use: get() or getUTC()
*/
offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number;
/**
* Zone abbreviation at given UTC timestamp e.g. CEST for Central European Summer Time.
*
* @param year Full year
* @param month Month 1-12 (note this deviates from JavaScript date)
* @param day Day of month 1-31
* @param hour Hour 0-23
* @param minute Minute 0-59
* @param second Second 0-59
* @param millisecond Millisecond 0-999
* @param dstDependent (default true) set to false for a DST-agnostic abbreviation
*
* @return "local" for local timezone, the offset for an offset zone, or the abbreviation for a proper zone.
*/
abbreviationForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, dstDependent?: boolean): string;
/**
* Normalizes non-existing local times by adding a forward offset change.
* During a forward standard offset change or DST offset change, some amount of