mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Add typings for timezonecomplete-1.10.0
This commit is contained in:
1207
timezonecomplete/timezonecomplete-1.9.0.d.ts
vendored
Normal file
1207
timezonecomplete/timezonecomplete-1.9.0.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
205
timezonecomplete/timezonecomplete-tests-1.9.0.ts
Normal file
205
timezonecomplete/timezonecomplete-tests-1.9.0.ts
Normal file
@@ -0,0 +1,205 @@
|
||||
/// <reference path="timezonecomplete-1.9.0.d.ts" />
|
||||
|
||||
import tc = require("timezonecomplete-1.9.0");
|
||||
|
||||
var b: boolean;
|
||||
var n: number;
|
||||
var s: string;
|
||||
var w: tc.WeekDay;
|
||||
|
||||
n = tc.timeUnitToMilliseconds(tc.TimeUnit.Month);
|
||||
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
|
||||
|
||||
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();
|
||||
var d8: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second);
|
||||
|
||||
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.weekNumber();
|
||||
n = dt.weekOfMonth();
|
||||
n = dt.secondOfDay();
|
||||
n = dt.dayOfYear();
|
||||
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();
|
||||
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();
|
||||
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()));
|
||||
dt = dt.min(new tc.DateTime(9289234, tc.TimeZone.local()));
|
||||
dt = dt.max(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();
|
||||
b = p.isBoundary(dt);
|
||||
|
||||
|
||||
// GLOBALS
|
||||
d = tc.min(tc.Duration.seconds(2), tc.Duration.seconds(3));
|
||||
d = tc.max(tc.Duration.seconds(2), tc.Duration.seconds(3));
|
||||
|
||||
dt = tc.min(new tc.DateTime(2), new tc.DateTime(3));
|
||||
dt = tc.max(new tc.DateTime(2), new tc.DateTime(3));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,10 +26,14 @@ 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();
|
||||
var d8: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second);
|
||||
var d5: tc.Duration = tc.hours(24);
|
||||
var d6: tc.Duration = tc.minutes(24);
|
||||
var d7: tc.Duration = tc.seconds(24);
|
||||
var d8: tc.Duration = tc.milliseconds(24);
|
||||
var d9: tc.Duration = new tc.Duration(24);
|
||||
var d10: tc.Duration = new tc.Duration("00:01");
|
||||
var d11: tc.Duration = d6.clone();
|
||||
var d12: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second);
|
||||
|
||||
n = d7.wholeHours();
|
||||
n = d7.hours();
|
||||
@@ -59,10 +63,16 @@ t = tc.TimeZone.local();
|
||||
t = tc.TimeZone.utc();
|
||||
t = tc.TimeZone.zone(2);
|
||||
t = tc.TimeZone.zone("+01:00");
|
||||
t = tc.local();
|
||||
t = tc.utc();
|
||||
t = tc.zone(2);
|
||||
t = tc.zone("+01:00");
|
||||
t = tc.zone("Europe/Amsterdam", false);
|
||||
s = t.name();
|
||||
k = t.kind();
|
||||
b = t.equals(t);
|
||||
b = t.isUtc();
|
||||
b = t.dst();
|
||||
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);
|
||||
@@ -84,6 +94,9 @@ var ts: tc.TimeSource = tc.DateTime.timeSource;
|
||||
dt = tc.DateTime.nowLocal();
|
||||
dt = tc.DateTime.nowUtc();
|
||||
dt = tc.DateTime.now(tc.TimeZone.local());
|
||||
dt = tc.nowLocal();
|
||||
dt = tc.nowUtc();
|
||||
dt = tc.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());
|
||||
|
||||
122
timezonecomplete/timezonecomplete.d.ts
vendored
122
timezonecomplete/timezonecomplete.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for timezonecomplete 1.9.0
|
||||
// Type definitions for timezonecomplete 1.10.0
|
||||
// Project: https://github.com/SpiritIT/timezonecomplete
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -22,8 +22,15 @@ declare module 'timezonecomplete' {
|
||||
export import secondOfDay = basics.secondOfDay;
|
||||
import datetime = require("__timezonecomplete/datetime");
|
||||
export import DateTime = datetime.DateTime;
|
||||
export import now = datetime.now;
|
||||
export import nowLocal = datetime.nowLocal;
|
||||
export import nowUtc = datetime.nowUtc;
|
||||
import duration = require("__timezonecomplete/duration");
|
||||
export import Duration = duration.Duration;
|
||||
export import hours = duration.hours;
|
||||
export import minutes = duration.minutes;
|
||||
export import seconds = duration.seconds;
|
||||
export import milliseconds = duration.milliseconds;
|
||||
import javascript = require("__timezonecomplete/javascript");
|
||||
export import DateFunctions = javascript.DateFunctions;
|
||||
import period = require("__timezonecomplete/period");
|
||||
@@ -37,6 +44,9 @@ declare module 'timezonecomplete' {
|
||||
export import NormalizeOption = timezone.NormalizeOption;
|
||||
export import TimeZoneKind = timezone.TimeZoneKind;
|
||||
export import TimeZone = timezone.TimeZone;
|
||||
export import local = timezone.local;
|
||||
export import utc = timezone.utc;
|
||||
export import zone = timezone.zone;
|
||||
import globals = require("__timezonecomplete/globals");
|
||||
export import min = globals.min;
|
||||
export import max = globals.max;
|
||||
@@ -299,9 +309,22 @@ declare module '__timezonecomplete/basics' {
|
||||
declare module '__timezonecomplete/datetime' {
|
||||
import basics = require("__timezonecomplete/basics");
|
||||
import duration = require("__timezonecomplete/duration");
|
||||
import javascript = require("__timezonecomplete/javascript");
|
||||
import timesource = require("__timezonecomplete/timesource");
|
||||
import javascript = require("__timezonecomplete/javascript");
|
||||
import timezone = require("__timezonecomplete/timezone");
|
||||
/**
|
||||
* Current date+time in local time
|
||||
*/
|
||||
export function nowLocal(): DateTime;
|
||||
/**
|
||||
* Current date+time in UTC time
|
||||
*/
|
||||
export function nowUtc(): DateTime;
|
||||
/**
|
||||
* Current date+time in the given time zone
|
||||
* @param timeZone The desired time zone (optional, defaults to UTC).
|
||||
*/
|
||||
export function now(timeZone?: timezone.TimeZone): DateTime;
|
||||
/**
|
||||
* DateTime class which is time zone-aware
|
||||
* and which can be mocked for testing purposes.
|
||||
@@ -314,18 +337,18 @@ declare module '__timezonecomplete/datetime' {
|
||||
*/
|
||||
static timeSource: timesource.TimeSource;
|
||||
/**
|
||||
* Current date+time in local time (derived from DateTime.timeSource.now()).
|
||||
* Current date+time in local time
|
||||
*/
|
||||
static nowLocal(): DateTime;
|
||||
/**
|
||||
* Current date+time in UTC time (derived from DateTime.timeSource.now()).
|
||||
* Current date+time in UTC time
|
||||
*/
|
||||
static nowUtc(): DateTime;
|
||||
/**
|
||||
* Current date+time in the given time zone (derived from DateTime.timeSource.now()).
|
||||
* @param timeZone The desired time zone.
|
||||
* Current date+time in the given time zone
|
||||
* @param timeZone The desired time zone (optional, defaults to UTC).
|
||||
*/
|
||||
static now(timeZone: timezone.TimeZone): DateTime;
|
||||
static now(timeZone?: timezone.TimeZone): DateTime;
|
||||
/**
|
||||
* Constructor. Creates current time in local timezone.
|
||||
*/
|
||||
@@ -673,6 +696,30 @@ declare module '__timezonecomplete/datetime' {
|
||||
|
||||
declare module '__timezonecomplete/duration' {
|
||||
import basics = require("__timezonecomplete/basics");
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of hours (may be fractional or negative)
|
||||
* @return A duration of n hours
|
||||
*/
|
||||
export function hours(n: number): Duration;
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of minutes (may be fractional or negative)
|
||||
* @return A duration of n minutes
|
||||
*/
|
||||
export function minutes(n: number): Duration;
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of seconds (may be fractional or negative)
|
||||
* @return A duration of n seconds
|
||||
*/
|
||||
export function seconds(n: number): Duration;
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of milliseconds (may be fractional or negative)
|
||||
* @return A duration of n milliseconds
|
||||
*/
|
||||
export function milliseconds(n: number): Duration;
|
||||
/**
|
||||
* Time duration. Create one e.g. like this: var d = Duration.hours(1).
|
||||
* Note that time durations do not take leap seconds etc. into account:
|
||||
@@ -681,25 +728,25 @@ declare module '__timezonecomplete/duration' {
|
||||
export class Duration {
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of hours
|
||||
* @param n Number of hours (may be fractional or negative)
|
||||
* @return A duration of n hours
|
||||
*/
|
||||
static hours(n: number): Duration;
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of minutes
|
||||
* @param n Number of minutes (may be fractional or negative)
|
||||
* @return A duration of n minutes
|
||||
*/
|
||||
static minutes(n: number): Duration;
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of seconds
|
||||
* @param n Number of seconds (may be fractional or negative)
|
||||
* @return A duration of n seconds
|
||||
*/
|
||||
static seconds(n: number): Duration;
|
||||
/**
|
||||
* Construct a time duration
|
||||
* @param n Number of milliseconds
|
||||
* @param n Number of milliseconds (may be fractional or negative)
|
||||
* @return A duration of n milliseconds
|
||||
*/
|
||||
static milliseconds(n: number): Duration;
|
||||
@@ -993,6 +1040,35 @@ declare module '__timezonecomplete/timesource' {
|
||||
|
||||
declare module '__timezonecomplete/timezone' {
|
||||
import javascript = require("__timezonecomplete/javascript");
|
||||
/**
|
||||
* The local time zone for a given date as per OS settings. Note that time zones are cached
|
||||
* so you don't necessarily get a new object each time.
|
||||
*/
|
||||
export function local(): TimeZone;
|
||||
/**
|
||||
* Coordinated Universal Time zone. Note that time zones are cached
|
||||
* so you don't necessarily get a new object each time.
|
||||
*/
|
||||
export function utc(): TimeZone;
|
||||
/**
|
||||
* @param offset offset w.r.t. UTC in minutes, e.g. 90 for +01:30. Note that time zones are cached
|
||||
* so you don't necessarily get a new object each time.
|
||||
* @returns a time zone with the given fixed offset
|
||||
*/
|
||||
export function zone(offset: number): TimeZone;
|
||||
/**
|
||||
* Time zone for an offset string or an IANA time zone string. Note that time zones are cached
|
||||
* so you don't necessarily get a new object each time.
|
||||
* @param s Empty string for no time zone (null is returned),
|
||||
* "localtime" for local time,
|
||||
* a TZ database time zone name (e.g. Europe/Amsterdam),
|
||||
* or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see:
|
||||
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
* @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for
|
||||
* "localtime", timezonecomplete will adhere to the computer settings, the DST flag
|
||||
* does not have any effect.
|
||||
*/
|
||||
export function zone(name: string, dst?: boolean): TimeZone;
|
||||
/**
|
||||
* The type of time zone
|
||||
*/
|
||||
@@ -1046,29 +1122,37 @@ declare module '__timezonecomplete/timezone' {
|
||||
*/
|
||||
static utc(): TimeZone;
|
||||
/**
|
||||
* Returns a time zone object from the cache. If it does not exist, it is created.
|
||||
* @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30
|
||||
* Time zone with a fixed offset
|
||||
* @param offset offset w.r.t. UTC in minutes, e.g. 90 for +01:30
|
||||
*/
|
||||
static zone(offset: number): TimeZone;
|
||||
/**
|
||||
* Returns a time zone object from the cache. If it does not exist, it is created.
|
||||
* @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam)
|
||||
* or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see:
|
||||
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
* Time zone for an offset string or an IANA time zone string. Note that time zones are cached
|
||||
* so you don't necessarily get a new object each time.
|
||||
* @param s Empty string for no time zone (null is returned),
|
||||
* "localtime" for local time,
|
||||
* a TZ database time zone name (e.g. Europe/Amsterdam),
|
||||
* or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see:
|
||||
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
* @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for
|
||||
* "localtime", timezonecomplete will adhere to the computer settings, the DST flag
|
||||
* does not have any effect.
|
||||
*/
|
||||
static zone(s: string): TimeZone;
|
||||
static zone(s: string, dst?: boolean): TimeZone;
|
||||
/**
|
||||
* Do not use this constructor, use the static
|
||||
* TimeZone.zone() method instead.
|
||||
* @param name NORMALIZED name, assumed to be correct
|
||||
* @param dst Adhere to Daylight Saving Time if applicable, ignored for local time and fixed offsets
|
||||
*/
|
||||
constructor(name: string);
|
||||
constructor(name: string, dst?: boolean);
|
||||
/**
|
||||
* The time zone identifier. Can be an offset "-01:30" or an
|
||||
* IANA time zone name "Europe/Amsterdam", or "localtime" for
|
||||
* the local time zone.
|
||||
*/
|
||||
name(): string;
|
||||
dst(): boolean;
|
||||
/**
|
||||
* The kind of time zone (Local/Offset/Proper)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user