diff --git a/history/history.d.ts b/history/history.d.ts
index a8a3c4004..07a31d011 100644
--- a/history/history.d.ts
+++ b/history/history.d.ts
@@ -1,13 +1,13 @@
-// Type definitions for History.js
-// Project: https://github.com/balupton/History.js
-// Definitions by: Boris Yankov
+// Type definitions for History.js 1.8.0
+// Project: https://github.com/browserstate/history.js
+// Definitions by: Boris Yankov , Gidon Junge
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface HistoryAdapter {
- bind(element, event, callback);
- trigger(element, event);
- onDomLoad(callback);
+ bind(element: any, event: string, callback: () => void);
+ trigger(element: any, event: string);
+ onDomLoad(callback: () => void);
}
// Since History is defined in lib.d.ts as well
@@ -17,15 +17,45 @@ interface HistoryAdapter {
// var Historyjs: Historyjs = History;
interface Historyjs {
+
enabled: boolean;
- pushState(data, title, url);
- replaceState(data, title, url);
- getState();
- getHash();
+
+ pushState(data: any, title: string, url: string);
+ replaceState(data: any, title: string, url: string);
+ getState(): HistoryState;
+ getStateByIndex(index: number): HistoryState;
+ getCurrentIndex(): number;
+ getHash(): string;
+
Adapter: HistoryAdapter;
- back();
- forward();
- go(X);
- log(...messages: any[]);
- debug(...messages: any[]);
+
+ back(): void;
+ forward(): void;
+ go(x: Number): void;
+
+ log(...messages: any[]): void;
+ debug(...messages: any[]): void;
+
+ options: HistoryOptions;
}
+
+interface HistoryState {
+ data?: any;
+ title?: string;
+ url: string;
+}
+
+interface HistoryOptions {
+ hashChangeInterval?: number;
+ safariPollInterval?: number;
+ doubleCheckInterval?: number;
+ disableSuid?: boolean;
+ storeInterval?: number;
+ busyDelay?: number;
+ debug?: boolean;
+ initialTitle?: string;
+ html4Mode?: boolean;
+ delayInit?: number;
+
+
+}
\ No newline at end of file
diff --git a/jquery.pjax.falsandtru/jquery.pjax-tests.ts b/jquery.pjax.falsandtru/jquery.pjax-tests.ts
index 18eae623c..f116da5df 100644
--- a/jquery.pjax.falsandtru/jquery.pjax-tests.ts
+++ b/jquery.pjax.falsandtru/jquery.pjax-tests.ts
@@ -1,35 +1,35 @@
-///
-///
-
-function test_pjax() {
- $.pjax();
-}
-
-function test_pjax_selector() {
- $('a').pjax();
-}
-
-function test_pjax_option() {
- $.pjax({
- area: 'body',
- load: {
- head: 'base, meta, link',
- css: true,
- script: true
- },
- cache: { click: true, submit: false, popstate: true },
- server: { query: null }
- });
-}
-
-function test_pjax_event() {
- $.pjax({
- wait: 1000
- });
- $(document).bind('pjax.request', function () {
- $('div.loading').fadeIn(100);
- });
- $(document).bind('pjax.render', function () {
- $('div.loading').fadeOut(500);
- });
-}
+///
+///
+
+function test_pjax() {
+ $.pjax();
+}
+
+function test_pjax_selector() {
+ $('a').pjax();
+}
+
+function test_pjax_option() {
+ $.pjax({
+ area: 'body',
+ load: {
+ head: 'base, meta, link',
+ css: true,
+ script: true
+ },
+ cache: { click: true, submit: false, popstate: true },
+ server: { query: null }
+ });
+}
+
+function test_pjax_event() {
+ $.pjax({
+ wait: 1000
+ });
+ $(document).bind('pjax.request', function () {
+ $('div.loading').fadeIn(100);
+ });
+ $(document).bind('pjax.render', function () {
+ $('div.loading').fadeOut(500);
+ });
+}
diff --git a/jquery.pjax.falsandtru/jquery.pjax.d.ts b/jquery.pjax.falsandtru/jquery.pjax.d.ts
index 07bc153df..36be74018 100644
--- a/jquery.pjax.falsandtru/jquery.pjax.d.ts
+++ b/jquery.pjax.falsandtru/jquery.pjax.d.ts
@@ -1,189 +1,189 @@
-// Type definitions for jquery.pjax.ts by falsandtru
-// Project: https://github.com/falsandtru/jquery.pjax.js/
-// Definitions by: 新ゝ月 NewNotMoon
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-
-interface PjaxSetting {
- gns?: string;
- ns?: string;
- area?: any; // string, array, function( event, param, origUrl, destUrl )
- link?: string;
- filter?: any; // string, function()
- form?: string;
- scope?: Object;
- state?: any; // any, function(event, param, origUrl, destUrl )
- scrollTop?: any; // number, function( event, param, origUrl, destUrl ), null, false
- scrollLeft?: any; // number, function( event, param, origUrl, destUrl ), null, false
- scroll?: {
- delay?: number;
- record?: boolean //internal
- queue?: number[] //internal
- };
- ajax?: JQueryAjaxSettings;
- contentType?: string;
- load?: {
- head?: string;
- css?: boolean;
- script?: boolean;
- execute?: boolean;
- reload?: string;
- ignore?: string;
- sync?: boolean;
- ajax?: JQueryAjaxSettings;
- rewrite?: (element: any) => any;
- redirect?: boolean;
- };
- interval?: number;
- cache?: {
- click?: boolean;
- submit?: boolean;
- popstate?: boolean;
- get?: boolean;
- post?: boolean;
- page?: boolean;
- size?: number;
- mix?: number;
- expires?: {
- min?: number;
- max?: number;
- };
- };
- wait?: any; // number, function( event, param, origUrl, destUrl ): number
- fallback?: any; // boolean, function( event, param, origUrl, destUrl ): boolean
- fix?: {
- location?: boolean;
- history?: boolean;
- scroll?: boolean;
- reset?: boolean;
- };
- database?: boolean;
- server?: {
- query?: any; // string, object
- header?: {
- area?: boolean;
- head?: boolean;
- css?: boolean;
- script?: boolean;
- };
- };
- callback?: (event: JQueryEventObject, param: any) => any;
- callbacks?: {
- before?: (event: JQueryEventObject, param: any) => any;
- after?: (event: JQueryEventObject, param: any) => any;
- ajax?: {
- xhr?: (event: JQueryEventObject, param: any) => any;
- beforeSend?: (event: JQueryEventObject, param: any, data: any, ajaxSettings: any) => any;
- dataFilter?: (event: JQueryEventObject, param: any, data: any, dataType: any) => any;
- success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- error?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any;
- complete?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any;
- done?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- fail?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any;
- always?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any;
- };
- update?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- cache?: {
- before?: (event: JQueryEventObject, param: any, cache: any) => any;
- after?: (event: JQueryEventObject, param: any, cache: any) => any;
- };
- redirect?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- url?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- title?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- head?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- content?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- scroll?: {
- before?: (event: JQueryEventObject, param: any) => any;
- after?: (event: JQueryEventObject, param: any) => any;
- };
- css?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- script?: {
- before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- render?: {
- before?: (event: JQueryEventObject, param: any) => any;
- after?: (event: JQueryEventObject, param: any) => any;
- };
- verify?: {
- before?: (event: JQueryEventObject, param: any) => any;
- after?: (event: JQueryEventObject, param: any) => any;
- };
- success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- error?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- complete?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
- };
- param?: any;
-
- // internal
- uuid?: string;
- nss?: {
- name?: string;
- event?: string[];
- click?: string;
- submit?: string;
- popstate?: string;
- scroll?: string;
- data?: string;
- class4html?: string;
- requestHeader?: string;
- };
- origLocation?: HTMLAnchorElement;
- destLocation?: HTMLAnchorElement;
- retry?: boolean;
- speedcheck?: boolean;
- disable?: boolean;
- option?: any;
- };
-}
-
-interface JQueryStatic {
- pjax: {
- (setting?: PjaxSetting): any;
- enable(): any;
- disable(): any;
- click(url: string, attr: { href?: string; }): any;
- click(url: HTMLAnchorElement, attr: { href?: string; }): any;
- click(url: JQuery, attr: { href?: string; }): any;
- click(url: any, attr: { href?: string; }): any;
- submit(url: string, attr: { action?: string; method?: string; }, data: any): any;
- submit(url: HTMLFormElement, attr?: { action?: string; method?: string; }, data?: any): any;
- submit(url: JQuery, attr?: { action?: string; method?: string; }, data?: any): any;
- submit(url: any, attr?: { action?: string; method?: string; }, data?: any): any;
- follow(event: JQueryEventObject, ajax: JQueryXHR, timeStamp?: number): boolean;
- setCache(): any;
- setCache(url: string): any;
- setCache(url: string, data: string): any;
- setCache(url: string, data: string, textStatus: string, XMLHttpRequest: XMLHttpRequest): any;
- getCache(): any;
- getCache(url: string): any;
- removeCache(url: string): any;
- removeCache(): any;
- clearCache(): any;
- };
-}
-
-interface JQuery {
- pjax(setting?: PjaxSetting): any;
+// Type definitions for jquery.pjax.ts by falsandtru
+// Project: https://github.com/falsandtru/jquery.pjax.js/
+// Definitions by: 新ゝ月 NewNotMoon
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+interface PjaxSetting {
+ gns?: string;
+ ns?: string;
+ area?: any; // string, array, function( event, param, origUrl, destUrl )
+ link?: string;
+ filter?: any; // string, function()
+ form?: string;
+ scope?: Object;
+ state?: any; // any, function(event, param, origUrl, destUrl )
+ scrollTop?: any; // number, function( event, param, origUrl, destUrl ), null, false
+ scrollLeft?: any; // number, function( event, param, origUrl, destUrl ), null, false
+ scroll?: {
+ delay?: number;
+ record?: boolean //internal
+ queue?: number[] //internal
+ };
+ ajax?: JQueryAjaxSettings;
+ contentType?: string;
+ load?: {
+ head?: string;
+ css?: boolean;
+ script?: boolean;
+ execute?: boolean;
+ reload?: string;
+ ignore?: string;
+ sync?: boolean;
+ ajax?: JQueryAjaxSettings;
+ rewrite?: (element: any) => any;
+ redirect?: boolean;
+ };
+ interval?: number;
+ cache?: {
+ click?: boolean;
+ submit?: boolean;
+ popstate?: boolean;
+ get?: boolean;
+ post?: boolean;
+ page?: boolean;
+ size?: number;
+ mix?: number;
+ expires?: {
+ min?: number;
+ max?: number;
+ };
+ };
+ wait?: any; // number, function( event, param, origUrl, destUrl ): number
+ fallback?: any; // boolean, function( event, param, origUrl, destUrl ): boolean
+ fix?: {
+ location?: boolean;
+ history?: boolean;
+ scroll?: boolean;
+ reset?: boolean;
+ };
+ database?: boolean;
+ server?: {
+ query?: any; // string, object
+ header?: {
+ area?: boolean;
+ head?: boolean;
+ css?: boolean;
+ script?: boolean;
+ };
+ };
+ callback?: (event: JQueryEventObject, param: any) => any;
+ callbacks?: {
+ before?: (event: JQueryEventObject, param: any) => any;
+ after?: (event: JQueryEventObject, param: any) => any;
+ ajax?: {
+ xhr?: (event: JQueryEventObject, param: any) => any;
+ beforeSend?: (event: JQueryEventObject, param: any, data: any, ajaxSettings: any) => any;
+ dataFilter?: (event: JQueryEventObject, param: any, data: any, dataType: any) => any;
+ success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ error?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any;
+ complete?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any;
+ done?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ fail?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any;
+ always?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any;
+ };
+ update?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ cache?: {
+ before?: (event: JQueryEventObject, param: any, cache: any) => any;
+ after?: (event: JQueryEventObject, param: any, cache: any) => any;
+ };
+ redirect?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ url?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ title?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ head?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ content?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ scroll?: {
+ before?: (event: JQueryEventObject, param: any) => any;
+ after?: (event: JQueryEventObject, param: any) => any;
+ };
+ css?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ script?: {
+ before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ render?: {
+ before?: (event: JQueryEventObject, param: any) => any;
+ after?: (event: JQueryEventObject, param: any) => any;
+ };
+ verify?: {
+ before?: (event: JQueryEventObject, param: any) => any;
+ after?: (event: JQueryEventObject, param: any) => any;
+ };
+ success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ error?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ complete?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
+ };
+ param?: any;
+
+ // internal
+ uuid?: string;
+ nss?: {
+ name?: string;
+ event?: string[];
+ click?: string;
+ submit?: string;
+ popstate?: string;
+ scroll?: string;
+ data?: string;
+ class4html?: string;
+ requestHeader?: string;
+ };
+ origLocation?: HTMLAnchorElement;
+ destLocation?: HTMLAnchorElement;
+ retry?: boolean;
+ speedcheck?: boolean;
+ disable?: boolean;
+ option?: any;
+ };
+}
+
+interface JQueryStatic {
+ pjax: {
+ (setting?: PjaxSetting): any;
+ enable(): any;
+ disable(): any;
+ click(url: string, attr: { href?: string; }): any;
+ click(url: HTMLAnchorElement, attr: { href?: string; }): any;
+ click(url: JQuery, attr: { href?: string; }): any;
+ click(url: any, attr: { href?: string; }): any;
+ submit(url: string, attr: { action?: string; method?: string; }, data: any): any;
+ submit(url: HTMLFormElement, attr?: { action?: string; method?: string; }, data?: any): any;
+ submit(url: JQuery, attr?: { action?: string; method?: string; }, data?: any): any;
+ submit(url: any, attr?: { action?: string; method?: string; }, data?: any): any;
+ follow(event: JQueryEventObject, ajax: JQueryXHR, timeStamp?: number): boolean;
+ setCache(): any;
+ setCache(url: string): any;
+ setCache(url: string, data: string): any;
+ setCache(url: string, data: string, textStatus: string, XMLHttpRequest: XMLHttpRequest): any;
+ getCache(): any;
+ getCache(url: string): any;
+ removeCache(url: string): any;
+ removeCache(): any;
+ clearCache(): any;
+ };
+}
+
+interface JQuery {
+ pjax(setting?: PjaxSetting): any;
}
\ No newline at end of file
diff --git a/js-url/js-url-tests.ts b/js-url/js-url-tests.ts
index 0b26f6175..e5d3eaece 100644
--- a/js-url/js-url-tests.ts
+++ b/js-url/js-url-tests.ts
@@ -1,9 +1,9 @@
-///
-
-url();
-
-url('domain');
-url(1);
-
-url('domain', 'test.www.example.com/path/here');
-url(-1, 'test.www.example.com/path/here');
+///
+
+url();
+
+url('domain');
+url(1);
+
+url('domain', 'test.www.example.com/path/here');
+url(-1, 'test.www.example.com/path/here');
diff --git a/promise-pool/promise-pool-tests.ts b/promise-pool/promise-pool-tests.ts
index 783d571ca..4f3bd40de 100644
--- a/promise-pool/promise-pool-tests.ts
+++ b/promise-pool/promise-pool-tests.ts
@@ -1,47 +1,47 @@
-import Q = require('q');
-import promisePool = require('promise-pool');
-
-var pool = new promisePool.Pool((taskDataId, index) => {
- return Q.delay(Math.floor(Math.random() * 5000)).then(function () {
- taskDataId == 0;
- index == 0;
- });
-}, 20);
-
-pool
- .pause()
- .delay(5000)
- .then(function () {
- pool.resume();
- });
-
-pool.retries == 0;
-pool.retryInterval == 0;
-pool.maxRetryInterval == 0;
-pool.retryIntervalMultiplier == 0;
-
-pool.add(0);
-
-pool
- .start(onProgress)
- .then(result => {
- result.total == 0;
- return pool.reset();
- })
- .then(() => {
- return pool.start(onProgress);
- })
- .then(result => {
- result.total == 0;
- return pool.reset();
- })
- .then(() => {
- pool.endless == true;
- });
-
-function onProgress(progress: promisePool.IProgress) {
- progress.success == true;
- progress.fulfilled == 0;
- progress.total == 0;
- progress.index == 0;
+import Q = require('q');
+import promisePool = require('promise-pool');
+
+var pool = new promisePool.Pool((taskDataId, index) => {
+ return Q.delay(Math.floor(Math.random() * 5000)).then(function () {
+ taskDataId == 0;
+ index == 0;
+ });
+}, 20);
+
+pool
+ .pause()
+ .delay(5000)
+ .then(function () {
+ pool.resume();
+ });
+
+pool.retries == 0;
+pool.retryInterval == 0;
+pool.maxRetryInterval == 0;
+pool.retryIntervalMultiplier == 0;
+
+pool.add(0);
+
+pool
+ .start(onProgress)
+ .then(result => {
+ result.total == 0;
+ return pool.reset();
+ })
+ .then(() => {
+ return pool.start(onProgress);
+ })
+ .then(result => {
+ result.total == 0;
+ return pool.reset();
+ })
+ .then(() => {
+ pool.endless == true;
+ });
+
+function onProgress(progress: promisePool.IProgress) {
+ progress.success == true;
+ progress.fulfilled == 0;
+ progress.total == 0;
+ progress.index == 0;
}
\ No newline at end of file
diff --git a/promise-pool/promise-pool.d.ts b/promise-pool/promise-pool.d.ts
index b9214e7f0..03cf5892b 100644
--- a/promise-pool/promise-pool.d.ts
+++ b/promise-pool/promise-pool.d.ts
@@ -1,124 +1,124 @@
-// Type definitions for promise-pool
-// Project: https://github.com/vilic/promise-pool
-// Definitions by: VILIC VANE
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-
-declare module "promise-pool" {
- /**
- * interface for the final result.
- */
- export interface IResult {
- fulfilled: number;
- rejected: number;
- total: number;
- }
- /**
- * interface for progress data.
- */
- export interface IProgress {
- index: number;
- success: boolean;
- error: any;
- retries: number;
- fulfilled: number;
- rejected: number;
- pending: number;
- total: number;
- }
- /**
- * tasks pool that manages concurrency.
- */
- export class Pool {
- /**
- * (get/set) the max concurrency of this task pool.
- */
- public concurrency: number;
- private _tasksData;
- /**
- * (get/set) the processor function that handles tasks data.
- */
- public processor: (data: T, index: number) => Q.IPromise;
- private _deferred;
- private _pauseDeferred;
- /**
- * (get) the number of successful tasks.
- */
- public fulfilled: number;
- /**
- * (get) the number of failed tasks.
- */
- public rejected: number;
- /**
- * (get) the number of pending tasks.
- */
- public pending: number;
- /**
- * (get) the number of completed tasks and pending tasks in total.
- */
- public total: number;
- /**
- * (get/set) indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled.
- */
- public endless: boolean;
- /**
- * (get/set) defaults to 0, the number or retries that this task pool will take for every single task, could be Infinity.
- */
- public retries: number;
- /**
- * (get/set) defaults to 0, interval (milliseconds) between each retries.
- */
- public retryInterval: number;
- /**
- * (get/set) defaults to Infinity, max retry interval when retry interval multiplier applied.
- */
- public maxRetryInterval: number;
- /**
- * (get/set) defaults to 1, the multiplier applies to interval after every retry.
- */
- public retryIntervalMultiplier: number;
- private _index;
- private _currentConcurrency;
- public onProgress: (progress: IProgress) => void;
- /**
- * initialize a task pool.
- * @param processor a function takes the data and index as parameters and returns a promise.
- * @param concurrency the concurrency of this task pool.
- * @param endless defaults to false. indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled.
- * @param tasksData an initializing array of task data.
- */
- constructor(processor: (data: T, index: number) => Q.IPromise, concurrency: number, endless?: boolean, tasksData?: T[]);
- /**
- * add a data item.
- * @param taskData task data to add.
- */
- public add(taskData: T): void;
- /**
- * add data items.
- * @param tasskData tasks data to add.
- */
- public add(tasksData: T[]): void;
- /**
- * start tasks, return a promise that will be fulfilled after all tasks accomplish if endless is false.
- * @param onProgress a callback that will be triggered every time when a single task is fulfilled.
- */
- public start(onProgress?: (progress: IProgress) => void): Q.Promise;
- private _start();
- private _process(data, index);
- private _notifyProgress(index, success, err, retries);
- private _next();
- /**
- * pause tasks and return a promise that will be fulfilled after the running tasks accomplish. this will wait for running tasks to complete instead of aborting them.
- */
- public pause(): Q.Promise;
- /**
- * resume tasks.
- */
- public resume(): void;
- /**
- * pause tasks, then clear pending tasks data and reset counters. return a promise that will be fulfilled after resetting accomplish.
- */
- public reset(): Q.Promise;
- }
+// Type definitions for promise-pool
+// Project: https://github.com/vilic/promise-pool
+// Definitions by: VILIC VANE
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "promise-pool" {
+ /**
+ * interface for the final result.
+ */
+ export interface IResult {
+ fulfilled: number;
+ rejected: number;
+ total: number;
+ }
+ /**
+ * interface for progress data.
+ */
+ export interface IProgress {
+ index: number;
+ success: boolean;
+ error: any;
+ retries: number;
+ fulfilled: number;
+ rejected: number;
+ pending: number;
+ total: number;
+ }
+ /**
+ * tasks pool that manages concurrency.
+ */
+ export class Pool {
+ /**
+ * (get/set) the max concurrency of this task pool.
+ */
+ public concurrency: number;
+ private _tasksData;
+ /**
+ * (get/set) the processor function that handles tasks data.
+ */
+ public processor: (data: T, index: number) => Q.IPromise;
+ private _deferred;
+ private _pauseDeferred;
+ /**
+ * (get) the number of successful tasks.
+ */
+ public fulfilled: number;
+ /**
+ * (get) the number of failed tasks.
+ */
+ public rejected: number;
+ /**
+ * (get) the number of pending tasks.
+ */
+ public pending: number;
+ /**
+ * (get) the number of completed tasks and pending tasks in total.
+ */
+ public total: number;
+ /**
+ * (get/set) indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled.
+ */
+ public endless: boolean;
+ /**
+ * (get/set) defaults to 0, the number or retries that this task pool will take for every single task, could be Infinity.
+ */
+ public retries: number;
+ /**
+ * (get/set) defaults to 0, interval (milliseconds) between each retries.
+ */
+ public retryInterval: number;
+ /**
+ * (get/set) defaults to Infinity, max retry interval when retry interval multiplier applied.
+ */
+ public maxRetryInterval: number;
+ /**
+ * (get/set) defaults to 1, the multiplier applies to interval after every retry.
+ */
+ public retryIntervalMultiplier: number;
+ private _index;
+ private _currentConcurrency;
+ public onProgress: (progress: IProgress) => void;
+ /**
+ * initialize a task pool.
+ * @param processor a function takes the data and index as parameters and returns a promise.
+ * @param concurrency the concurrency of this task pool.
+ * @param endless defaults to false. indicates whether this task pool is endless, if so, tasks can still be added even after all previous tasks have been fulfilled.
+ * @param tasksData an initializing array of task data.
+ */
+ constructor(processor: (data: T, index: number) => Q.IPromise, concurrency: number, endless?: boolean, tasksData?: T[]);
+ /**
+ * add a data item.
+ * @param taskData task data to add.
+ */
+ public add(taskData: T): void;
+ /**
+ * add data items.
+ * @param tasskData tasks data to add.
+ */
+ public add(tasksData: T[]): void;
+ /**
+ * start tasks, return a promise that will be fulfilled after all tasks accomplish if endless is false.
+ * @param onProgress a callback that will be triggered every time when a single task is fulfilled.
+ */
+ public start(onProgress?: (progress: IProgress) => void): Q.Promise;
+ private _start();
+ private _process(data, index);
+ private _notifyProgress(index, success, err, retries);
+ private _next();
+ /**
+ * pause tasks and return a promise that will be fulfilled after the running tasks accomplish. this will wait for running tasks to complete instead of aborting them.
+ */
+ public pause(): Q.Promise;
+ /**
+ * resume tasks.
+ */
+ public resume(): void;
+ /**
+ * pause tasks, then clear pending tasks data and reset counters. return a promise that will be fulfilled after resetting accomplish.
+ */
+ public reset(): Q.Promise;
+ }
}
\ No newline at end of file
diff --git a/q-retry/q-retry-tests.ts b/q-retry/q-retry-tests.ts
index bf72f8ad7..e5d5dd8ca 100644
--- a/q-retry/q-retry-tests.ts
+++ b/q-retry/q-retry-tests.ts
@@ -1,39 +1,39 @@
-import Q = require('q-retry');
-
-Q
- .retry(() => {
- return '';
- })
- .then(str => {
- str.charAt;
- return 0;
- })
- .retry(num => {
- num.toFixed;
- })
- .retry(() => {
-
- }, 5)
- .retry(() => {
-
- }, (reason, retries) => {
- retries.toFixed;
- })
- .retry(() => {
-
- }, (reason, retries) => {
- retries.toFixed;
- }, 10)
- .retry(() => {
- return '';
- }, (reason, retries) => {
-
- }, {
- limit: 10,
- interval: 1000,
- maxInterval: 20000,
- intervalMultiplier: 1.5
- })
- .then(str => {
- str.charAt;
+import Q = require('q-retry');
+
+Q
+ .retry(() => {
+ return '';
+ })
+ .then(str => {
+ str.charAt;
+ return 0;
+ })
+ .retry(num => {
+ num.toFixed;
+ })
+ .retry(() => {
+
+ }, 5)
+ .retry(() => {
+
+ }, (reason, retries) => {
+ retries.toFixed;
+ })
+ .retry(() => {
+
+ }, (reason, retries) => {
+ retries.toFixed;
+ }, 10)
+ .retry(() => {
+ return '';
+ }, (reason, retries) => {
+
+ }, {
+ limit: 10,
+ interval: 1000,
+ maxInterval: 20000,
+ intervalMultiplier: 1.5
+ })
+ .then(str => {
+ str.charAt;
});
\ No newline at end of file
diff --git a/q-retry/q-retry.d.ts b/q-retry/q-retry.d.ts
index fe6b42fd8..f4e6e47d9 100644
--- a/q-retry/q-retry.d.ts
+++ b/q-retry/q-retry.d.ts
@@ -1,39 +1,39 @@
-// Type definitions for q-retry
-// Project: https://github.com/vilic/q-retry
-// Definitions by: VILIC VANE
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-
-declare module Q {
- export interface IRetryOptions {
- limit?: number;
- interval?: number;
- maxInterval?: number;
- intervalMultiplier?: number;
- }
-
- export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise;
- export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
- export function retry(process: () => IPromise, limit: number): Promise;
- export function retry(process: () => IPromise, options?: IRetryOptions): Promise;
- export function retry(process: () => U, onFail: (reason: any, retries: number) => void, limit: number): Promise;
- export function retry(process: () => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
- export function retry(process: () => U, limit: number): Promise;
- export function retry(process: () => U, options?: IRetryOptions): Promise;
-
- interface Promise {
- retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise;
- retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
- retry(process: (value: T) => IPromise, limit: number): Promise;
- retry(process: (value: T) => IPromise, options?: IRetryOptions): Promise;
- retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, limit: number): Promise;
- retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
- retry(process: (value: T) => U, limit: number): Promise;
- retry(process: (value: T) => U, options?: IRetryOptions): Promise;
- }
-}
-
-declare module "q-retry" {
- export = Q;
+// Type definitions for q-retry
+// Project: https://github.com/vilic/q-retry
+// Definitions by: VILIC VANE
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module Q {
+ export interface IRetryOptions {
+ limit?: number;
+ interval?: number;
+ maxInterval?: number;
+ intervalMultiplier?: number;
+ }
+
+ export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise;
+ export function retry(process: () => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
+ export function retry(process: () => IPromise, limit: number): Promise;
+ export function retry(process: () => IPromise, options?: IRetryOptions): Promise;
+ export function retry(process: () => U, onFail: (reason: any, retries: number) => void, limit: number): Promise;
+ export function retry(process: () => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
+ export function retry(process: () => U, limit: number): Promise;
+ export function retry(process: () => U, options?: IRetryOptions): Promise;
+
+ interface Promise {
+ retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, limit: number): Promise;
+ retry(process: (value: T) => IPromise, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
+ retry(process: (value: T) => IPromise, limit: number): Promise;
+ retry(process: (value: T) => IPromise, options?: IRetryOptions): Promise;
+ retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, limit: number): Promise;
+ retry(process: (value: T) => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise;
+ retry(process: (value: T) => U, limit: number): Promise;
+ retry(process: (value: T) => U, options?: IRetryOptions): Promise;
+ }
+}
+
+declare module "q-retry" {
+ export = Q;
}
\ No newline at end of file
diff --git a/timezonecomplete/timezonecomplete-1.3.0.d.ts b/timezonecomplete/timezonecomplete-1.3.0.d.ts
index d4960def4..602a44084 100644
--- a/timezonecomplete/timezonecomplete-1.3.0.d.ts
+++ b/timezonecomplete/timezonecomplete-1.3.0.d.ts
@@ -1,702 +1,702 @@
-// Type definitions for timezonecomplete 1.3.0
-// Project: https://github.com/SpiritIT/timezonecomplete
-// Definitions by: Rogier Schouten
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-// Generated by dts-bundle v0.2.0
-
-declare module 'timezonecomplete-1.3.0' {
- /**
- * @return True iff the given year is a leap year.
- */
- export function isLeapYear(year: number): boolean;
- /**
- * @param year The full year
- * @param month The month 1-12
- * @return The number of days in the given month
- */
- export function daysInMonth(year: number, month: number): number;
- /**
- * Returns an ISO time string. Note that months are 1-12.
- */
- export function isoString(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): string;
- /**
- * Time units
- */
- export enum TimeUnit {
- Second = 0,
- Minute = 1,
- Hour = 2,
- Day = 3,
- Week = 4,
- Month = 5,
- Year = 6,
- }
- /**
- * 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:
- * one hour is simply represented as 3600000 milliseconds.
- */
- export class Duration {
- /**
- * Construct a time duration
- * @param n Number of hours
- * @return A duration of n hours
- */
- static hours(n: number): Duration;
- /**
- * Construct a time duration
- * @param n Number of minutes
- * @return A duration of n minutes
- */
- static minutes(n: number): Duration;
- /**
- * Construct a time duration
- * @param n Number of seconds
- * @return A duration of n seconds
- */
- static seconds(n: number): Duration;
- /**
- * Construct a time duration
- * @param n Number of milliseconds
- * @return A duration of n milliseconds
- */
- static milliseconds(n: number): Duration;
- /**
- * Construct a time duration of 0
- */
- constructor();
- /**
- * Construct a time duration from a number of milliseconds
- */
- constructor(milliseconds: number);
- /**
- * Construct a time duration from a string in format
- * [-]h[:m[:s[.n]]] e.g. -01:00:30.501
- */
- constructor(input: string);
- /**
- * @return another instance of Duration with the same value.
- */
- clone(): Duration;
- /**
- * The entire duration in milliseconds (negative or positive)
- */
- milliseconds(): number;
- /**
- * The millisecond part of the duration (always positive)
- * @return e.g. 400 for a -01:02:03.400 duration
- */
- millisecond(): number;
- /**
- * The entire duration in seconds (negative or positive, fractional)
- * @return e.g. 1.5 for a 1500 milliseconds duration
- */
- seconds(): number;
- /**
- * The second part of the duration (always positive)
- * @return e.g. 3 for a -01:02:03.400 duration
- */
- second(): number;
- /**
- * The entire duration in minutes (negative or positive, fractional)
- * @return e.g. 1.5 for a 90000 milliseconds duration
- */
- minutes(): number;
- /**
- * The minute part of the duration (always positive)
- * @return e.g. 2 for a -01:02:03.400 duration
- */
- minute(): number;
- /**
- * The entire duration in hours (negative or positive, fractional)
- * @return e.g. 1.5 for a 5400000 milliseconds duration
- */
- hours(): number;
- /**
- * The hour part of the duration (always positive).
- * Note that this part can exceed 23 hours, because for
- * now, we do not have a days() function
- * @return e.g. 25 for a -25:02:03.400 duration
- */
- wholeHours(): number;
- /**
- * Sign
- * @return "-" if the duration is negative
- */
- sign(): string;
- /**
- * @return True iff (this < other)
- */
- lessThan(other: Duration): boolean;
- /**
- * @return True iff this and other represent the same time duration
- */
- equals(other: Duration): boolean;
- /**
- * @return True iff this > other
- */
- greaterThan(other: Duration): boolean;
- /**
- * @return The minimum (most negative) of this and other
- */
- min(other: Duration): Duration;
- /**
- * @return The maximum (most positive) of this and other
- */
- max(other: Duration): Duration;
- /**
- * Multiply with a fixed number.
- * @return a new Duration of (this * value)
- */
- multiply(value: number): Duration;
- /**
- * Divide by a fixed number.
- * @return a new Duration of (this / value)
- */
- divide(value: number): Duration;
- /**
- * Add a duration.
- * @return a new Duration of (this + value)
- */
- add(value: Duration): Duration;
- /**
- * Subtract a duration.
- * @return a new Duration of (this - value)
- */
- sub(value: Duration): Duration;
- /**
- * String in [-]hh:mm:ss.nnn notation. All fields are
- * always present except the sign.
- */
- toFullString(): string;
- /**
- * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are
- * added as necessary
- */
- toString(): string;
- }
- /**
- * The type of time zone
- */
- export enum TimeZoneKind {
- /**
- * Local time offset as determined by JavaScript Date class.
- */
- Local = 0,
- /**
- * Fixed offset from UTC, without DST.
- */
- Offset = 1,
- /**
- * IANA timezone managed through Olsen TZ database. Includes
- * DST if applicable.
- */
- Proper = 2,
- }
- /**
- * Time zone. The object is immutable because it is cached:
- * requesting a time zone twice yields the very same object.
- * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(),
- * i.e. offset 90 means +01:30.
- *
- * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date,
- * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST
- * applied depending on the time zone rules.
- */
- export class TimeZone {
- /**
- * The local time zone for a given date. Note that
- * the time zone varies with the date: amsterdam time for
- * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00
- */
- static local(): TimeZone;
- /**
- * The UTC time zone.
- */
- 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
- */
- 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
- */
- static zone(s: string): TimeZone;
- /**
- * 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;
- /**
- * The kind of time zone (Local/Offset/Proper)
- */
- kind(): TimeZoneKind;
- /**
- * Equality operator. Maps zero offsets and different names for UTC onto
- * each other. Other time zones are not mapped onto each other.
- */
- equals(other: TimeZone): boolean;
- /**
- * Is this zone equivalent to UTC?
- */
- isUtc(): 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
- * @return the offset of this time zone with respect to UTC at the given time.
- */
- offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
- /**
- * Calculate timezone offset from a zone-local time (NOT 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
- * @return the offset of this time zone with respect to UTC at the given time.
- */
- offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
- /**
- * Convenience function, takes values from a Javascript Date
- * Calls offsetForUtc() with the contents of the date
- * @param date: the date
- * @param funcs: the set of functions to use: get() or getUTC()
- */
- offsetForUtcDate(date: Date, funcs: DateFunctions): number;
- /**
- * Convenience function, takes values from a Javascript Date
- * Calls offsetForUtc() with the contents of the date
- * @param date: the date
- * @param funcs: the set of functions to use: get() or getUTC()
- */
- offsetForZoneDate(date: Date, funcs: DateFunctions): number;
- /**
- * The time zone identifier (normalized).
- * Either "localtime", IANA name, or "+hh:mm" offset.
- */
- toString(): string;
- /**
- * Convert an offset number into an offset string
- * @param offset The offset in minutes from UTC e.g. 90 minutes
- * @return the offset in ISO notation "+01:30" for +90 minutes
- */
- static offsetToString(offset: number): string;
- /**
- * String to offset conversion.
- * @param s Formats: "-01:00", "-0100", "-01", "Z"
- * @return offset w.r.t. UTC in minutes
- */
- static stringToOffset(s: string): number;
- }
- /**
- * For testing purposes, we often need to manipulate what the current
- * time is. This is an interface for a custom time source object
- * so in tests you can use a custom time source.
- */
- export interface TimeSource {
- /**
- * Return the current date+time as a javascript Date object
- */
- now(): Date;
- }
- /**
- * Default time source, returns actual time
- */
- export class RealTimeSource implements TimeSource {
- now(): Date;
- }
- /**
- * Indicates how a Date object should be interpreted.
- * Either we can take getYear(), getMonth() etc for our field
- * values, or we can take getUTCYear() etc to do that.
- */
- export enum DateFunctions {
- /**
- * Use the Date.getFullYear(), Date.getMonth(), ... functions.
- */
- Get = 0,
- /**
- * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions.
- */
- GetUTC = 1,
- }
- /**
- * Day-of-week. Note the enum values correspond to JavaScript day-of-week:
- * Sunday = 0, Monday = 1 etc
- */
- export enum WeekDay {
- Sunday = 0,
- Monday = 1,
- Tuesday = 2,
- Wednesday = 3,
- Thursday = 4,
- Friday = 5,
- Saturday = 6,
- }
- /**
- * Our very own DateTime class which is time zone-aware
- * and which can be mocked for testing purposes
- */
- export class DateTime {
- /**
- * Actual time source in use. Setting this property allows to
- * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc()
- * use this property for obtaining the current time.
- */
- static timeSource: TimeSource;
- /**
- * Current date+time in local time (derived from DateTime.timeSource.now()).
- */
- static nowLocal(): DateTime;
- /**
- * Current date+time in UTC time (derived from DateTime.timeSource.now()).
- */
- static nowUtc(): DateTime;
- /**
- * Current date+time in the given time zone (derived from DateTime.timeSource.now()).
- * @param timeZone The desired time zone.
- */
- static now(timeZone: TimeZone): DateTime;
- /**
- * Constructor. Creates current time in local timezone.
- */
- constructor();
- /**
- * Constructor
- * @param isoString String in ISO 8601 format. Instead of ISO time zone,
- * it may include a space and then and IANA time zone.
- * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date)
- * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time)
- * or "2007-04-05T12:30:40.500Z" (UTC)
- * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable)
- * @param timeZone if given, the date in the string is assumed to be in this time zone.
- * Note that it is NOT CONVERTED to the time zone. Useful
- * for strings without a time zone
- */
- constructor(isoString: string, timeZone?: TimeZone);
- /**
- * Constructor. You provide a date, then you say whether to take the
- * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods,
- * and then you state which time zone that date is in.
- *
- * @param date A date object.
- * @param getters Specifies which set of Date getters contains the date in the given time zone: the
- * Date.getXxx() methods or the Date.getUTCXxx() methods.
- * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates)
- */
- constructor(date: Date, getFuncs: DateFunctions, timeZone?: TimeZone);
- /**
- * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges.
- * Use the add(duration) or sub(duration) for arithmetic.
- * @param year The full year (e.g. 2014)
- * @param month The month [1-12] (note this deviates from JavaScript Date)
- * @param day The day of the month [1-31]
- * @param hour The hour of the day [0-24)
- * @param minute The minute of the hour [0-59]
- * @param second The second of the minute [0-59]
- * @param millisecond The millisecond of the second [0-999]
- * @param timeZone The time zone, or null (for unaware dates)
- */
- constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: TimeZone);
- /**
- * Constructor
- * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000
- * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC).
- */
- constructor(unixTimestamp: number, timeZone?: TimeZone);
- /**
- * @return a copy of this object
- */
- clone(): DateTime;
- /**
- * @return The time zone that the date is in. May be null for unaware dates.
- */
- zone(): TimeZone;
- /**
- * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates.
- */
- offset(): number;
- /**
- * @return The full year e.g. 2014
- */
- year(): number;
- /**
- * @return The month 1-12 (note this deviates from JavaScript Date)
- */
- month(): number;
- /**
- * @return The day of the month 1-31
- */
- day(): number;
- /**
- * @return The hour 0-23
- */
- hour(): number;
- /**
- * @return the minutes 0-59
- */
- minute(): number;
- /**
- * @return the seconds 0-59
- */
- second(): number;
- /**
- * @return the milliseconds 0-999
- */
- millisecond(): number;
- /**
- * @return the day-of-week (the enum values correspond to JavaScript
- * week day numbers)
- */
- weekDay(): WeekDay;
- /**
- * @return Milliseconds since 1970-01-01T00:00:00.000Z
- */
- unixUtcMillis(): number;
- /**
- * @return The full year e.g. 2014
- */
- utcYear(): number;
- /**
- * @return The UTC month 1-12 (note this deviates from JavaScript Date)
- */
- utcMonth(): number;
- /**
- * @return The UTC day of the month 1-31
- */
- utcDay(): number;
- /**
- * @return The UTC hour 0-23
- */
- utcHour(): number;
- /**
- * @return The UTC minutes 0-59
- */
- utcMinute(): number;
- /**
- * @return The UTC seconds 0-59
- */
- utcSecond(): number;
- /**
- * @return The UTC milliseconds 0-999
- */
- utcMillisecond(): number;
- /**
- * @return the UTC day-of-week (the enum values correspond to JavaScript
- * week day numbers)
- */
- utcWeekDay(): WeekDay;
- /**
- * Convert this date to the given time zone (in-place).
- * Throws if this date does not have a time zone.
- * @return this (for chaining)
- */
- convert(zone?: TimeZone): DateTime;
- /**
- * Returns this date converted to the given time zone.
- * Unaware dates can only be converted to unaware dates (clone)
- * For unaware dates, an exception is thrown
- * @param zone The new time zone. This may be null to create unaware date.
- * @return The converted date
- */
- toZone(zone?: TimeZone): DateTime;
- /**
- * Convert to JavaScript date with the zone time in the getX() methods.
- * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct.
- */
- toDate(): Date;
- /**
- * Add a time duration. Note that this simply adds a number
- * of milliseconds to UTC and converts back to zone(),
- * so in the presence of e.g. leap seconds there may be a
- * shift in the seconds field if you add an hour.
- * There is not DST handling and no leap second handling.
- * @return this + duration
- */
- add(duration: Duration): DateTime;
- /**
- * Add an amount of time to UTC, taking leap seconds etc into account.
- * Adding e.g. 1 hour will increment the utcHour() field
- * date by one. In case of DST changes, the local hour() field
- * may not increase or increase by 2 hours. So if you add a month, the
- * local time may vary by an hour. There will not be a shift
- * in seconds due to leap seconds.
- */
- add(amount: number, unit: TimeUnit): DateTime;
- /**
- * Add an amount of time to the zone time, as regularly as possible.
- * Adding e.g. 1 hour will increment the hour() field of the zone
- * date by one. In case of DST changes, the utcHour() field may
- * increase by 1 or increase by 2. Adding a day will leave the time portion
- * intact. However, adding an hour around a forward DST change adds two hours,
- * since there is a zone time (2AM in Holland) that does not exist.
- */
- addLocal(amount: number, unit: TimeUnit): DateTime;
- /**
- * Same as add(-1*duration);
- */
- sub(duration: Duration): DateTime;
- /**
- * Same as add(-1*amount, unit);
- */
- sub(amount: number, unit: TimeUnit): DateTime;
- /**
- * Same as addLocal(-1*amount, unit);
- */
- subLocal(amount: number, unit: TimeUnit): DateTime;
- /**
- * Time difference between two DateTimes
- * @return this - other
- */
- diff(other: DateTime): Duration;
- /**
- * @return True iff (this < other)
- */
- lessThan(other: DateTime): boolean;
- /**
- * @return True iff (this <= other)
- */
- lessEqual(other: DateTime): boolean;
- /**
- * @return True iff this and other represent the same time in UTC
- */
- equals(other: DateTime): boolean;
- /**
- * @return True iff this and other represent the same time and
- * have the same zone
- */
- identical(other: DateTime): boolean;
- /**
- * @return True iff this > other
- */
- greaterThan(other: DateTime): boolean;
- /**
- * @return True iff this >= other
- */
- greaterEqual(other: DateTime): boolean;
- /**
- * Proper ISO 8601 format string with any IANA zone converted to ISO offset
- * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam
- */
- toIsoString(): string;
- /**
- * Modified ISO 8601 format string with IANA name if applicable.
- * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam"
- */
- toString(): string;
- /**
- * Modified ISO 8601 format string in UTC without time zone info
- */
- toUtcString(): string;
- }
- /**
- * Specifies how the period should repeat across the day
- * during DST changes.
- */
- export enum PeriodDst {
- /**
- * Keep repeating in similar intervals measured in UTC,
- * unaffected by Daylight Saving Time.
- * E.g. a repetition of one hour will take one real hour
- * every time, even in a time zone with DST.
- * Leap seconds, leap days and month length
- * differences will still make the intervals different.
- */
- RegularIntervals = 0,
- /**
- * Ensure that the time at which the intervals occur stay
- * at the same place in the day, local time. So e.g.
- * a period of one day, starting at 8:05AM Europe/Amsterdam time
- * will always start at 8:05 Europe/Amsterdam. This means that
- * in UTC time, some intervals will be 25 hours and some
- * 23 hours during DST changes.
- * Another example: an hourly interval will be hourly in local time,
- * skipping an hour in UTC for a DST backward change.
- */
- RegularLocalTime = 1,
- }
- /**
- * Convert a PeriodDst to a string: "regular intervals" or "regular local time"
- */
- export function periodDstToString(p: PeriodDst): string;
- /**
- * Repeating time period: consists of a starting point and
- * a time length. This class accounts for leap seconds and leap days.
- */
- export class Period {
- /**
- * Constructor
- * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour,
- * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not.
- * This is due to the enormous processing power required by these cases. They are not
- * implemented and you will get an assert.
- *
- * @param start The start of the period. If the period is in Months or Years, and
- * the day is 29 or 30 or 31, the results are maximised to end-of-month.
- * @param amount The amount of units.
- * @param unit The unit.
- * @param dst Specifies how to handle Daylight Saving Time. Not relevant
- * if the time zone of the start datetime does not have DST.
- */
- constructor(start: DateTime, amount: number, unit: TimeUnit, dst: PeriodDst);
- /**
- * The start date
- */
- start(): DateTime;
- /**
- * The amount of units
- */
- amount(): number;
- /**
- * The unit
- */
- unit(): TimeUnit;
- /**
- * The dst handling mode
- */
- dst(): PeriodDst;
- /**
- * The first occurrence of the period greater than
- * the given date. The given date need not be at a period boundary.
- * Pre: the fromdate and startdate must either both have timezones or not
- * @param fromDate: the date after which to return the next date
- * @return the first date matching the period after fromDate, given
- * in the same zone as the fromDate.
- */
- findFirst(fromDate: DateTime): DateTime;
- /**
- * Returns the next timestamp in the period. The given timestamp must
- * be at a period boundary, otherwise the answer is incorrect.
- * This function has MUCH better performance than findFirst.
- * Returns the datetime "count" times away from the given datetime.
- * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one.
- * @param count Optional, must be >= 1 and whole.
- * @return (prev + count * period), in the same timezone as prev.
- */
- findNext(prev: DateTime, count?: number): DateTime;
- /**
- * Returns an ISO duration string
- * P[n]Y[n]M[n]DT[n]H[n]M[n][.n]S or P[n]W
- */
- toIsoString(): string;
- /**
- * A string representation e.g.
- * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam keeping regular intervals".
- */
- toString(): string;
- }
-}
-
+// Type definitions for timezonecomplete 1.3.0
+// Project: https://github.com/SpiritIT/timezonecomplete
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+// Generated by dts-bundle v0.2.0
+
+declare module 'timezonecomplete-1.3.0' {
+ /**
+ * @return True iff the given year is a leap year.
+ */
+ export function isLeapYear(year: number): boolean;
+ /**
+ * @param year The full year
+ * @param month The month 1-12
+ * @return The number of days in the given month
+ */
+ export function daysInMonth(year: number, month: number): number;
+ /**
+ * Returns an ISO time string. Note that months are 1-12.
+ */
+ export function isoString(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): string;
+ /**
+ * Time units
+ */
+ export enum TimeUnit {
+ Second = 0,
+ Minute = 1,
+ Hour = 2,
+ Day = 3,
+ Week = 4,
+ Month = 5,
+ Year = 6,
+ }
+ /**
+ * 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:
+ * one hour is simply represented as 3600000 milliseconds.
+ */
+ export class Duration {
+ /**
+ * Construct a time duration
+ * @param n Number of hours
+ * @return A duration of n hours
+ */
+ static hours(n: number): Duration;
+ /**
+ * Construct a time duration
+ * @param n Number of minutes
+ * @return A duration of n minutes
+ */
+ static minutes(n: number): Duration;
+ /**
+ * Construct a time duration
+ * @param n Number of seconds
+ * @return A duration of n seconds
+ */
+ static seconds(n: number): Duration;
+ /**
+ * Construct a time duration
+ * @param n Number of milliseconds
+ * @return A duration of n milliseconds
+ */
+ static milliseconds(n: number): Duration;
+ /**
+ * Construct a time duration of 0
+ */
+ constructor();
+ /**
+ * Construct a time duration from a number of milliseconds
+ */
+ constructor(milliseconds: number);
+ /**
+ * Construct a time duration from a string in format
+ * [-]h[:m[:s[.n]]] e.g. -01:00:30.501
+ */
+ constructor(input: string);
+ /**
+ * @return another instance of Duration with the same value.
+ */
+ clone(): Duration;
+ /**
+ * The entire duration in milliseconds (negative or positive)
+ */
+ milliseconds(): number;
+ /**
+ * The millisecond part of the duration (always positive)
+ * @return e.g. 400 for a -01:02:03.400 duration
+ */
+ millisecond(): number;
+ /**
+ * The entire duration in seconds (negative or positive, fractional)
+ * @return e.g. 1.5 for a 1500 milliseconds duration
+ */
+ seconds(): number;
+ /**
+ * The second part of the duration (always positive)
+ * @return e.g. 3 for a -01:02:03.400 duration
+ */
+ second(): number;
+ /**
+ * The entire duration in minutes (negative or positive, fractional)
+ * @return e.g. 1.5 for a 90000 milliseconds duration
+ */
+ minutes(): number;
+ /**
+ * The minute part of the duration (always positive)
+ * @return e.g. 2 for a -01:02:03.400 duration
+ */
+ minute(): number;
+ /**
+ * The entire duration in hours (negative or positive, fractional)
+ * @return e.g. 1.5 for a 5400000 milliseconds duration
+ */
+ hours(): number;
+ /**
+ * The hour part of the duration (always positive).
+ * Note that this part can exceed 23 hours, because for
+ * now, we do not have a days() function
+ * @return e.g. 25 for a -25:02:03.400 duration
+ */
+ wholeHours(): number;
+ /**
+ * Sign
+ * @return "-" if the duration is negative
+ */
+ sign(): string;
+ /**
+ * @return True iff (this < other)
+ */
+ lessThan(other: Duration): boolean;
+ /**
+ * @return True iff this and other represent the same time duration
+ */
+ equals(other: Duration): boolean;
+ /**
+ * @return True iff this > other
+ */
+ greaterThan(other: Duration): boolean;
+ /**
+ * @return The minimum (most negative) of this and other
+ */
+ min(other: Duration): Duration;
+ /**
+ * @return The maximum (most positive) of this and other
+ */
+ max(other: Duration): Duration;
+ /**
+ * Multiply with a fixed number.
+ * @return a new Duration of (this * value)
+ */
+ multiply(value: number): Duration;
+ /**
+ * Divide by a fixed number.
+ * @return a new Duration of (this / value)
+ */
+ divide(value: number): Duration;
+ /**
+ * Add a duration.
+ * @return a new Duration of (this + value)
+ */
+ add(value: Duration): Duration;
+ /**
+ * Subtract a duration.
+ * @return a new Duration of (this - value)
+ */
+ sub(value: Duration): Duration;
+ /**
+ * String in [-]hh:mm:ss.nnn notation. All fields are
+ * always present except the sign.
+ */
+ toFullString(): string;
+ /**
+ * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are
+ * added as necessary
+ */
+ toString(): string;
+ }
+ /**
+ * The type of time zone
+ */
+ export enum TimeZoneKind {
+ /**
+ * Local time offset as determined by JavaScript Date class.
+ */
+ Local = 0,
+ /**
+ * Fixed offset from UTC, without DST.
+ */
+ Offset = 1,
+ /**
+ * IANA timezone managed through Olsen TZ database. Includes
+ * DST if applicable.
+ */
+ Proper = 2,
+ }
+ /**
+ * Time zone. The object is immutable because it is cached:
+ * requesting a time zone twice yields the very same object.
+ * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(),
+ * i.e. offset 90 means +01:30.
+ *
+ * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date,
+ * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST
+ * applied depending on the time zone rules.
+ */
+ export class TimeZone {
+ /**
+ * The local time zone for a given date. Note that
+ * the time zone varies with the date: amsterdam time for
+ * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00
+ */
+ static local(): TimeZone;
+ /**
+ * The UTC time zone.
+ */
+ 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
+ */
+ 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
+ */
+ static zone(s: string): TimeZone;
+ /**
+ * 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;
+ /**
+ * The kind of time zone (Local/Offset/Proper)
+ */
+ kind(): TimeZoneKind;
+ /**
+ * Equality operator. Maps zero offsets and different names for UTC onto
+ * each other. Other time zones are not mapped onto each other.
+ */
+ equals(other: TimeZone): boolean;
+ /**
+ * Is this zone equivalent to UTC?
+ */
+ isUtc(): 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
+ * @return the offset of this time zone with respect to UTC at the given time.
+ */
+ offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
+ /**
+ * Calculate timezone offset from a zone-local time (NOT 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
+ * @return the offset of this time zone with respect to UTC at the given time.
+ */
+ offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
+ /**
+ * Convenience function, takes values from a Javascript Date
+ * Calls offsetForUtc() with the contents of the date
+ * @param date: the date
+ * @param funcs: the set of functions to use: get() or getUTC()
+ */
+ offsetForUtcDate(date: Date, funcs: DateFunctions): number;
+ /**
+ * Convenience function, takes values from a Javascript Date
+ * Calls offsetForUtc() with the contents of the date
+ * @param date: the date
+ * @param funcs: the set of functions to use: get() or getUTC()
+ */
+ offsetForZoneDate(date: Date, funcs: DateFunctions): number;
+ /**
+ * The time zone identifier (normalized).
+ * Either "localtime", IANA name, or "+hh:mm" offset.
+ */
+ toString(): string;
+ /**
+ * Convert an offset number into an offset string
+ * @param offset The offset in minutes from UTC e.g. 90 minutes
+ * @return the offset in ISO notation "+01:30" for +90 minutes
+ */
+ static offsetToString(offset: number): string;
+ /**
+ * String to offset conversion.
+ * @param s Formats: "-01:00", "-0100", "-01", "Z"
+ * @return offset w.r.t. UTC in minutes
+ */
+ static stringToOffset(s: string): number;
+ }
+ /**
+ * For testing purposes, we often need to manipulate what the current
+ * time is. This is an interface for a custom time source object
+ * so in tests you can use a custom time source.
+ */
+ export interface TimeSource {
+ /**
+ * Return the current date+time as a javascript Date object
+ */
+ now(): Date;
+ }
+ /**
+ * Default time source, returns actual time
+ */
+ export class RealTimeSource implements TimeSource {
+ now(): Date;
+ }
+ /**
+ * Indicates how a Date object should be interpreted.
+ * Either we can take getYear(), getMonth() etc for our field
+ * values, or we can take getUTCYear() etc to do that.
+ */
+ export enum DateFunctions {
+ /**
+ * Use the Date.getFullYear(), Date.getMonth(), ... functions.
+ */
+ Get = 0,
+ /**
+ * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions.
+ */
+ GetUTC = 1,
+ }
+ /**
+ * Day-of-week. Note the enum values correspond to JavaScript day-of-week:
+ * Sunday = 0, Monday = 1 etc
+ */
+ export enum WeekDay {
+ Sunday = 0,
+ Monday = 1,
+ Tuesday = 2,
+ Wednesday = 3,
+ Thursday = 4,
+ Friday = 5,
+ Saturday = 6,
+ }
+ /**
+ * Our very own DateTime class which is time zone-aware
+ * and which can be mocked for testing purposes
+ */
+ export class DateTime {
+ /**
+ * Actual time source in use. Setting this property allows to
+ * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc()
+ * use this property for obtaining the current time.
+ */
+ static timeSource: TimeSource;
+ /**
+ * Current date+time in local time (derived from DateTime.timeSource.now()).
+ */
+ static nowLocal(): DateTime;
+ /**
+ * Current date+time in UTC time (derived from DateTime.timeSource.now()).
+ */
+ static nowUtc(): DateTime;
+ /**
+ * Current date+time in the given time zone (derived from DateTime.timeSource.now()).
+ * @param timeZone The desired time zone.
+ */
+ static now(timeZone: TimeZone): DateTime;
+ /**
+ * Constructor. Creates current time in local timezone.
+ */
+ constructor();
+ /**
+ * Constructor
+ * @param isoString String in ISO 8601 format. Instead of ISO time zone,
+ * it may include a space and then and IANA time zone.
+ * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date)
+ * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time)
+ * or "2007-04-05T12:30:40.500Z" (UTC)
+ * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable)
+ * @param timeZone if given, the date in the string is assumed to be in this time zone.
+ * Note that it is NOT CONVERTED to the time zone. Useful
+ * for strings without a time zone
+ */
+ constructor(isoString: string, timeZone?: TimeZone);
+ /**
+ * Constructor. You provide a date, then you say whether to take the
+ * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods,
+ * and then you state which time zone that date is in.
+ *
+ * @param date A date object.
+ * @param getters Specifies which set of Date getters contains the date in the given time zone: the
+ * Date.getXxx() methods or the Date.getUTCXxx() methods.
+ * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates)
+ */
+ constructor(date: Date, getFuncs: DateFunctions, timeZone?: TimeZone);
+ /**
+ * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges.
+ * Use the add(duration) or sub(duration) for arithmetic.
+ * @param year The full year (e.g. 2014)
+ * @param month The month [1-12] (note this deviates from JavaScript Date)
+ * @param day The day of the month [1-31]
+ * @param hour The hour of the day [0-24)
+ * @param minute The minute of the hour [0-59]
+ * @param second The second of the minute [0-59]
+ * @param millisecond The millisecond of the second [0-999]
+ * @param timeZone The time zone, or null (for unaware dates)
+ */
+ constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: TimeZone);
+ /**
+ * Constructor
+ * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000
+ * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC).
+ */
+ constructor(unixTimestamp: number, timeZone?: TimeZone);
+ /**
+ * @return a copy of this object
+ */
+ clone(): DateTime;
+ /**
+ * @return The time zone that the date is in. May be null for unaware dates.
+ */
+ zone(): TimeZone;
+ /**
+ * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates.
+ */
+ offset(): number;
+ /**
+ * @return The full year e.g. 2014
+ */
+ year(): number;
+ /**
+ * @return The month 1-12 (note this deviates from JavaScript Date)
+ */
+ month(): number;
+ /**
+ * @return The day of the month 1-31
+ */
+ day(): number;
+ /**
+ * @return The hour 0-23
+ */
+ hour(): number;
+ /**
+ * @return the minutes 0-59
+ */
+ minute(): number;
+ /**
+ * @return the seconds 0-59
+ */
+ second(): number;
+ /**
+ * @return the milliseconds 0-999
+ */
+ millisecond(): number;
+ /**
+ * @return the day-of-week (the enum values correspond to JavaScript
+ * week day numbers)
+ */
+ weekDay(): WeekDay;
+ /**
+ * @return Milliseconds since 1970-01-01T00:00:00.000Z
+ */
+ unixUtcMillis(): number;
+ /**
+ * @return The full year e.g. 2014
+ */
+ utcYear(): number;
+ /**
+ * @return The UTC month 1-12 (note this deviates from JavaScript Date)
+ */
+ utcMonth(): number;
+ /**
+ * @return The UTC day of the month 1-31
+ */
+ utcDay(): number;
+ /**
+ * @return The UTC hour 0-23
+ */
+ utcHour(): number;
+ /**
+ * @return The UTC minutes 0-59
+ */
+ utcMinute(): number;
+ /**
+ * @return The UTC seconds 0-59
+ */
+ utcSecond(): number;
+ /**
+ * @return The UTC milliseconds 0-999
+ */
+ utcMillisecond(): number;
+ /**
+ * @return the UTC day-of-week (the enum values correspond to JavaScript
+ * week day numbers)
+ */
+ utcWeekDay(): WeekDay;
+ /**
+ * Convert this date to the given time zone (in-place).
+ * Throws if this date does not have a time zone.
+ * @return this (for chaining)
+ */
+ convert(zone?: TimeZone): DateTime;
+ /**
+ * Returns this date converted to the given time zone.
+ * Unaware dates can only be converted to unaware dates (clone)
+ * For unaware dates, an exception is thrown
+ * @param zone The new time zone. This may be null to create unaware date.
+ * @return The converted date
+ */
+ toZone(zone?: TimeZone): DateTime;
+ /**
+ * Convert to JavaScript date with the zone time in the getX() methods.
+ * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct.
+ */
+ toDate(): Date;
+ /**
+ * Add a time duration. Note that this simply adds a number
+ * of milliseconds to UTC and converts back to zone(),
+ * so in the presence of e.g. leap seconds there may be a
+ * shift in the seconds field if you add an hour.
+ * There is not DST handling and no leap second handling.
+ * @return this + duration
+ */
+ add(duration: Duration): DateTime;
+ /**
+ * Add an amount of time to UTC, taking leap seconds etc into account.
+ * Adding e.g. 1 hour will increment the utcHour() field
+ * date by one. In case of DST changes, the local hour() field
+ * may not increase or increase by 2 hours. So if you add a month, the
+ * local time may vary by an hour. There will not be a shift
+ * in seconds due to leap seconds.
+ */
+ add(amount: number, unit: TimeUnit): DateTime;
+ /**
+ * Add an amount of time to the zone time, as regularly as possible.
+ * Adding e.g. 1 hour will increment the hour() field of the zone
+ * date by one. In case of DST changes, the utcHour() field may
+ * increase by 1 or increase by 2. Adding a day will leave the time portion
+ * intact. However, adding an hour around a forward DST change adds two hours,
+ * since there is a zone time (2AM in Holland) that does not exist.
+ */
+ addLocal(amount: number, unit: TimeUnit): DateTime;
+ /**
+ * Same as add(-1*duration);
+ */
+ sub(duration: Duration): DateTime;
+ /**
+ * Same as add(-1*amount, unit);
+ */
+ sub(amount: number, unit: TimeUnit): DateTime;
+ /**
+ * Same as addLocal(-1*amount, unit);
+ */
+ subLocal(amount: number, unit: TimeUnit): DateTime;
+ /**
+ * Time difference between two DateTimes
+ * @return this - other
+ */
+ diff(other: DateTime): Duration;
+ /**
+ * @return True iff (this < other)
+ */
+ lessThan(other: DateTime): boolean;
+ /**
+ * @return True iff (this <= other)
+ */
+ lessEqual(other: DateTime): boolean;
+ /**
+ * @return True iff this and other represent the same time in UTC
+ */
+ equals(other: DateTime): boolean;
+ /**
+ * @return True iff this and other represent the same time and
+ * have the same zone
+ */
+ identical(other: DateTime): boolean;
+ /**
+ * @return True iff this > other
+ */
+ greaterThan(other: DateTime): boolean;
+ /**
+ * @return True iff this >= other
+ */
+ greaterEqual(other: DateTime): boolean;
+ /**
+ * Proper ISO 8601 format string with any IANA zone converted to ISO offset
+ * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam
+ */
+ toIsoString(): string;
+ /**
+ * Modified ISO 8601 format string with IANA name if applicable.
+ * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam"
+ */
+ toString(): string;
+ /**
+ * Modified ISO 8601 format string in UTC without time zone info
+ */
+ toUtcString(): string;
+ }
+ /**
+ * Specifies how the period should repeat across the day
+ * during DST changes.
+ */
+ export enum PeriodDst {
+ /**
+ * Keep repeating in similar intervals measured in UTC,
+ * unaffected by Daylight Saving Time.
+ * E.g. a repetition of one hour will take one real hour
+ * every time, even in a time zone with DST.
+ * Leap seconds, leap days and month length
+ * differences will still make the intervals different.
+ */
+ RegularIntervals = 0,
+ /**
+ * Ensure that the time at which the intervals occur stay
+ * at the same place in the day, local time. So e.g.
+ * a period of one day, starting at 8:05AM Europe/Amsterdam time
+ * will always start at 8:05 Europe/Amsterdam. This means that
+ * in UTC time, some intervals will be 25 hours and some
+ * 23 hours during DST changes.
+ * Another example: an hourly interval will be hourly in local time,
+ * skipping an hour in UTC for a DST backward change.
+ */
+ RegularLocalTime = 1,
+ }
+ /**
+ * Convert a PeriodDst to a string: "regular intervals" or "regular local time"
+ */
+ export function periodDstToString(p: PeriodDst): string;
+ /**
+ * Repeating time period: consists of a starting point and
+ * a time length. This class accounts for leap seconds and leap days.
+ */
+ export class Period {
+ /**
+ * Constructor
+ * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour,
+ * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not.
+ * This is due to the enormous processing power required by these cases. They are not
+ * implemented and you will get an assert.
+ *
+ * @param start The start of the period. If the period is in Months or Years, and
+ * the day is 29 or 30 or 31, the results are maximised to end-of-month.
+ * @param amount The amount of units.
+ * @param unit The unit.
+ * @param dst Specifies how to handle Daylight Saving Time. Not relevant
+ * if the time zone of the start datetime does not have DST.
+ */
+ constructor(start: DateTime, amount: number, unit: TimeUnit, dst: PeriodDst);
+ /**
+ * The start date
+ */
+ start(): DateTime;
+ /**
+ * The amount of units
+ */
+ amount(): number;
+ /**
+ * The unit
+ */
+ unit(): TimeUnit;
+ /**
+ * The dst handling mode
+ */
+ dst(): PeriodDst;
+ /**
+ * The first occurrence of the period greater than
+ * the given date. The given date need not be at a period boundary.
+ * Pre: the fromdate and startdate must either both have timezones or not
+ * @param fromDate: the date after which to return the next date
+ * @return the first date matching the period after fromDate, given
+ * in the same zone as the fromDate.
+ */
+ findFirst(fromDate: DateTime): DateTime;
+ /**
+ * Returns the next timestamp in the period. The given timestamp must
+ * be at a period boundary, otherwise the answer is incorrect.
+ * This function has MUCH better performance than findFirst.
+ * Returns the datetime "count" times away from the given datetime.
+ * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one.
+ * @param count Optional, must be >= 1 and whole.
+ * @return (prev + count * period), in the same timezone as prev.
+ */
+ findNext(prev: DateTime, count?: number): DateTime;
+ /**
+ * Returns an ISO duration string
+ * P[n]Y[n]M[n]DT[n]H[n]M[n][.n]S or P[n]W
+ */
+ toIsoString(): string;
+ /**
+ * A string representation e.g.
+ * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam keeping regular intervals".
+ */
+ toString(): string;
+ }
+}
+
diff --git a/timezonecomplete/timezonecomplete-1.4.6.d.ts b/timezonecomplete/timezonecomplete-1.4.6.d.ts
index bd70278d5..afec37d0f 100644
--- a/timezonecomplete/timezonecomplete-1.4.6.d.ts
+++ b/timezonecomplete/timezonecomplete-1.4.6.d.ts
@@ -1,1004 +1,1004 @@
-// Type definitions for timezonecomplete 1.4.6
-// Project: https://github.com/SpiritIT/timezonecomplete
-// Definitions by: Rogier Schouten
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-// Generated by dts-bundle v0.2.0
-
-declare module 'timezonecomplete-1.4.6' {
- import basics = require("__timezonecomplete/basics");
- export import TimeUnit = basics.TimeUnit;
- export import WeekDay = basics.WeekDay;
- export import isLeapYear = basics.isLeapYear;
- export import daysInMonth = basics.daysInMonth;
- export import daysInYear = basics.daysInYear;
- export import dayOfYear = basics.dayOfYear;
- export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth;
- export import weekDayOnOrAfter = basics.weekDayOnOrAfter;
- export import weekDayOnOrBefore = basics.weekDayOnOrBefore;
- import datetime = require("__timezonecomplete/datetime");
- export import DateTime = datetime.DateTime;
- import duration = require("__timezonecomplete/duration");
- export import Duration = duration.Duration;
- import javascript = require("__timezonecomplete/javascript");
- export import DateFunctions = javascript.DateFunctions;
- import period = require("__timezonecomplete/period");
- export import Period = period.Period;
- export import PeriodDst = period.PeriodDst;
- export import periodDstToString = period.periodDstToString;
- import timesource = require("__timezonecomplete/timesource");
- export import TimeSource = timesource.TimeSource;
- export import RealTimeSource = timesource.RealTimeSource;
- import timezone = require("__timezonecomplete/timezone");
- export import NormalizeOption = timezone.NormalizeOption;
- export import TimeZoneKind = timezone.TimeZoneKind;
- export import TimeZone = timezone.TimeZone;
-}
-
-declare module '__timezonecomplete/basics' {
- import javascript = require("__timezonecomplete/javascript");
- /**
- * Day-of-week. Note the enum values correspond to JavaScript day-of-week:
- * Sunday = 0, Monday = 1 etc
- */
- export enum WeekDay {
- Sunday = 0,
- Monday = 1,
- Tuesday = 2,
- Wednesday = 3,
- Thursday = 4,
- Friday = 5,
- Saturday = 6,
- }
- /**
- * Time units
- */
- export enum TimeUnit {
- Second = 0,
- Minute = 1,
- Hour = 2,
- Day = 3,
- Week = 4,
- Month = 5,
- Year = 6,
- }
- /**
- * @return True iff the given year is a leap year.
- */
- export function isLeapYear(year: number): boolean;
- /**
- * The days in a given year
- */
- export function daysInYear(year: number): number;
- /**
- * @param year The full year
- * @param month The month 1-12
- * @return The number of days in the given month
- */
- export function daysInMonth(year: number, month: number): number;
- /**
- * Returns the day of the year of the given date [0..365]. January first is 0.
- *
- * @param year The year e.g. 1986
- * @param month Month 1-12
- * @param day Day of month 1-31
- */
- export function dayOfYear(year: number, month: number, day: number): number;
- /**
- * Returns the last 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 last occurrence of the week day in the month
- */
- export function lastWeekDayOfMonth(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.
- */
- export function weekDayOnOrAfter(year: number, month: number, day: 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.
- */
- export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number;
- /**
- * Convert a unix milli timestamp into a TimeT structure.
- * This does NOT take leap seconds into account.
- */
- export function unixToTimeNoLeapSecs(unixMillis: number): TimeStruct;
- /**
- * Convert a year, month, day etc into a unix milli timestamp.
- * This does NOT take leap seconds into account.
- *
- * @param year Year e.g. 1970
- * @param month Month 1-12
- * @param day Day 1-31
- * @param hour Hour 0-23
- * @param minute Minute 0-59
- * @param second Second 0-59 (no leap seconds)
- * @param milli Millisecond 0-999
- */
- export function timeToUnixNoLeapSecs(year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, milli?: number): number;
- /**
- * Convert a TimeT structure into a unix milli timestamp.
- * This does NOT take leap seconds into account.
- */
- export function timeToUnixNoLeapSecs(tm: TimeStruct): number;
- /**
- * Return the day-of-week.
- * This does NOT take leap seconds into account.
- */
- export function weekDayNoLeapSecs(unixMillis: number): WeekDay;
- /**
- * Basic representation of a date and time
- */
- export class TimeStruct {
- /**
- * Year, 1970-...
- */
- year: number;
- /**
- * Month 1-12
- */
- month: number;
- /**
- * Day of month, 1-31
- */
- day: number;
- /**
- * Hour 0-23
- */
- hour: number;
- /**
- * Minute 0-59
- */
- minute: number;
- /**
- * Seconds, 0-59
- */
- second: number;
- /**
- * Milliseconds 0-999
- */
- milli: number;
- /**
- * Create a TimeStruct from a number of unix milliseconds
- */
- static fromUnix(unixMillis: number): TimeStruct;
- /**
- * Create a TimeStruct from a JavaScript date
- *
- * @param d The date
- * @param df Which functions to take (getX() or getUTCX())
- */
- static fromDate(d: Date, df: javascript.DateFunctions): TimeStruct;
- /**
- * Returns a TimeStruct from an ISO 8601 string WITHOUT time zone
- */
- static fromString(s: string): TimeStruct;
- /**
- * Constructor
- *
- * @param year Year e.g. 1970
- * @param month Month 1-12
- * @param day Day 1-31
- * @param hour Hour 0-23
- * @param minute Minute 0-59
- * @param second Second 0-59 (no leap seconds)
- * @param milli Millisecond 0-999
- */
- constructor(/**
- * Year, 1970-...
- */
- year?: number, /**
- * Month 1-12
- */
- month?: number, /**
- * Day of month, 1-31
- */
- day?: number, /**
- * Hour 0-23
- */
- hour?: number, /**
- * Minute 0-59
- */
- minute?: number, /**
- * Seconds, 0-59
- */
- second?: number, /**
- * Milliseconds 0-999
- */
- milli?: number);
- /**
- * Validate a TimeStruct, returns false if invalid.
- */
- validate(): boolean;
- /**
- * The day-of-year 0-365
- */
- yearDay(): number;
- /**
- * Returns this time as a unix millisecond timestamp
- * Does NOT take leap seconds into account.
- */
- toUnixNoLeapSecs(): number;
- /**
- * Deep equals
- */
- equals(other: TimeStruct): boolean;
- /**
- * < operator
- */
- lessThan(other: TimeStruct): boolean;
- clone(): TimeStruct;
- valueOf(): number;
- /**
- * ISO 8601 string YYYY-MM-DDThh:mm:ss.nnn
- */
- toString(): string;
- inspect(): string;
- }
-}
-
-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 timezone = require("__timezonecomplete/timezone");
- /**
- * DateTime class which is time zone-aware
- * and which can be mocked for testing purposes.
- */
- export class DateTime {
- /**
- * Actual time source in use. Setting this property allows to
- * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc()
- * use this property for obtaining the current time.
- */
- static timeSource: timesource.TimeSource;
- /**
- * Current date+time in local time (derived from DateTime.timeSource.now()).
- */
- static nowLocal(): DateTime;
- /**
- * Current date+time in UTC time (derived from DateTime.timeSource.now()).
- */
- static nowUtc(): DateTime;
- /**
- * Current date+time in the given time zone (derived from DateTime.timeSource.now()).
- * @param timeZone The desired time zone.
- */
- static now(timeZone: timezone.TimeZone): DateTime;
- /**
- * Constructor. Creates current time in local timezone.
- */
- constructor();
- /**
- * Constructor
- * Non-existing local times are normalized by rounding up to the next DST offset.
- *
- * @param isoString String in ISO 8601 format. Instead of ISO time zone,
- * it may include a space and then and IANA time zone.
- * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date)
- * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time)
- * or "2007-04-05T12:30:40.500Z" (UTC)
- * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable)
- * @param timeZone if given, the date in the string is assumed to be in this time zone.
- * Note that it is NOT CONVERTED to the time zone. Useful
- * for strings without a time zone
- */
- constructor(isoString: string, timeZone?: timezone.TimeZone);
- /**
- * Constructor. You provide a date, then you say whether to take the
- * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods,
- * and then you state which time zone that date is in.
- * Non-existing local times are normalized by rounding up to the next DST offset.
- * Note that the Date class has bugs and inconsistencies when constructing them with times around
- * DST changes.
- *
- * @param date A date object.
- * @param getters Specifies which set of Date getters contains the date in the given time zone: the
- * Date.getXxx() methods or the Date.getUTCXxx() methods.
- * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates)
- */
- constructor(date: Date, getFuncs: javascript.DateFunctions, timeZone?: timezone.TimeZone);
- /**
- * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges.
- * Use the add(duration) or sub(duration) for arithmetic.
- * @param year The full year (e.g. 2014)
- * @param month The month [1-12] (note this deviates from JavaScript Date)
- * @param day The day of the month [1-31]
- * @param hour The hour of the day [0-24)
- * @param minute The minute of the hour [0-59]
- * @param second The second of the minute [0-59]
- * @param millisecond The millisecond of the second [0-999]
- * @param timeZone The time zone, or null (for unaware dates)
- */
- constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: timezone.TimeZone);
- /**
- * Constructor
- * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000
- * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC).
- */
- constructor(unixTimestamp: number, timeZone?: timezone.TimeZone);
- /**
- * @return a copy of this object
- */
- clone(): DateTime;
- /**
- * @return The time zone that the date is in. May be null for unaware dates.
- */
- zone(): timezone.TimeZone;
- /**
- * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates.
- */
- offset(): number;
- /**
- * @return The full year e.g. 2014
- */
- year(): number;
- /**
- * @return The month 1-12 (note this deviates from JavaScript Date)
- */
- month(): number;
- /**
- * @return The day of the month 1-31
- */
- day(): number;
- /**
- * @return The hour 0-23
- */
- hour(): number;
- /**
- * @return the minutes 0-59
- */
- minute(): number;
- /**
- * @return the seconds 0-59
- */
- second(): number;
- /**
- * @return the milliseconds 0-999
- */
- millisecond(): number;
- /**
- * @return the day-of-week (the enum values correspond to JavaScript
- * week day numbers)
- */
- weekDay(): basics.WeekDay;
- /**
- * @return Milliseconds since 1970-01-01T00:00:00.000Z
- */
- unixUtcMillis(): number;
- /**
- * @return The full year e.g. 2014
- */
- utcYear(): number;
- /**
- * @return The UTC month 1-12 (note this deviates from JavaScript Date)
- */
- utcMonth(): number;
- /**
- * @return The UTC day of the month 1-31
- */
- utcDay(): number;
- /**
- * @return The UTC hour 0-23
- */
- utcHour(): number;
- /**
- * @return The UTC minutes 0-59
- */
- utcMinute(): number;
- /**
- * @return The UTC seconds 0-59
- */
- utcSecond(): number;
- /**
- * @return The UTC milliseconds 0-999
- */
- utcMillisecond(): number;
- /**
- * @return the UTC day-of-week (the enum values correspond to JavaScript
- * week day numbers)
- */
- utcWeekDay(): basics.WeekDay;
- /**
- * Convert this date to the given time zone (in-place).
- * Throws if this date does not have a time zone.
- * @return this (for chaining)
- */
- convert(zone?: timezone.TimeZone): DateTime;
- /**
- * Returns this date converted to the given time zone.
- * Unaware dates can only be converted to unaware dates (clone)
- * Converting an unaware date to an aware date throws an exception. Use the constructor
- * if you really need to do that.
- *
- * @param zone The new time zone. This may be null to create unaware date.
- * @return The converted date
- */
- toZone(zone?: timezone.TimeZone): DateTime;
- /**
- * Convert to JavaScript date with the zone time in the getX() methods.
- * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct.
- * This is because Date calculates getUTCX() from getX() applying local time zone.
- */
- toDate(): Date;
- /**
- * Add a time duration relative to UTC. Note that this simply adds a number
- * of milliseconds to UTC and converts back to zone(),
- * There is not DST handling.
- * @return this + duration
- */
- add(duration: duration.Duration): DateTime;
- /**
- * Add an amount of time relative to UTC, as regularly as possible.
- *
- * Adding e.g. 1 hour will increment the utcHour() field, adding 1 month
- * increments the utcMonth() field.
- * Adding an amount of units leaves lower units intact. E.g.
- * adding a month will leave the day() field untouched if possible.
- *
- * Note adding Months or Years will clamp the date to the end-of-month if
- * the start date was at the end of a month, i.e. contrary to JavaScript
- * Date#setUTCMonth() it will not overflow into the next month
- *
- * In case of DST changes, the utc time fields are still untouched but local
- * time fields may shift.
- */
- add(amount: number, unit: basics.TimeUnit): DateTime;
- /**
- * Add an amount of time to the zone time, as regularly as possible.
- *
- * Adding e.g. 1 hour will increment the hour() field of the zone
- * date by one. In case of DST changes, the time fields may additionally
- * increase by the DST offset, if a non-existing local time would
- * be reached otherwise.
- *
- * Adding a unit of time will leave lower-unit fields intact, unless the result
- * would be a non-existing time. Then an extra DST offset is added.
- *
- * Note adding Months or Years will clamp the date to the end-of-month if
- * the start date was at the end of a month, i.e. contrary to JavaScript
- * Date#setUTCMonth() it will not overflow into the next month
- */
- addLocal(amount: number, unit: basics.TimeUnit): DateTime;
- /**
- * Same as add(-1*duration);
- */
- sub(duration: duration.Duration): DateTime;
- /**
- * Same as add(-1*amount, unit);
- */
- sub(amount: number, unit: basics.TimeUnit): DateTime;
- /**
- * Same as addLocal(-1*amount, unit);
- */
- subLocal(amount: number, unit: basics.TimeUnit): DateTime;
- /**
- * Time difference between two DateTimes
- * @return this - other
- */
- diff(other: DateTime): duration.Duration;
- /**
- * @return True iff (this < other)
- */
- lessThan(other: DateTime): boolean;
- /**
- * @return True iff (this <= other)
- */
- lessEqual(other: DateTime): boolean;
- /**
- * @return True iff this and other represent the same time in UTC
- */
- equals(other: DateTime): boolean;
- /**
- * @return True iff this and other represent the same time and
- * have the same zone
- */
- identical(other: DateTime): boolean;
- /**
- * @return True iff this > other
- */
- greaterThan(other: DateTime): boolean;
- /**
- * @return True iff this >= other
- */
- greaterEqual(other: DateTime): boolean;
- /**
- * Proper ISO 8601 format string with any IANA zone converted to ISO offset
- * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam
- */
- toIsoString(): string;
- /**
- * Modified ISO 8601 format string with IANA name if applicable.
- * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam"
- */
- toString(): string;
- /**
- * Used by util.inspect()
- */
- inspect(): string;
- /**
- * Modified ISO 8601 format string in UTC without time zone info
- */
- toUtcString(): string;
- }
-}
-
-declare module '__timezonecomplete/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:
- * one hour is simply represented as 3600000 milliseconds.
- */
- export class Duration {
- /**
- * Construct a time duration
- * @param n Number of hours
- * @return A duration of n hours
- */
- static hours(n: number): Duration;
- /**
- * Construct a time duration
- * @param n Number of minutes
- * @return A duration of n minutes
- */
- static minutes(n: number): Duration;
- /**
- * Construct a time duration
- * @param n Number of seconds
- * @return A duration of n seconds
- */
- static seconds(n: number): Duration;
- /**
- * Construct a time duration
- * @param n Number of milliseconds
- * @return A duration of n milliseconds
- */
- static milliseconds(n: number): Duration;
- /**
- * Construct a time duration of 0
- */
- constructor();
- /**
- * Construct a time duration from a number of milliseconds
- */
- constructor(milliseconds: number);
- /**
- * Construct a time duration from a string in format
- * [-]h[:m[:s[.n]]] e.g. -01:00:30.501
- */
- constructor(input: string);
- /**
- * @return another instance of Duration with the same value.
- */
- clone(): Duration;
- /**
- * The entire duration in milliseconds (negative or positive)
- */
- milliseconds(): number;
- /**
- * The millisecond part of the duration (always positive)
- * @return e.g. 400 for a -01:02:03.400 duration
- */
- millisecond(): number;
- /**
- * The entire duration in seconds (negative or positive, fractional)
- * @return e.g. 1.5 for a 1500 milliseconds duration
- */
- seconds(): number;
- /**
- * The second part of the duration (always positive)
- * @return e.g. 3 for a -01:02:03.400 duration
- */
- second(): number;
- /**
- * The entire duration in minutes (negative or positive, fractional)
- * @return e.g. 1.5 for a 90000 milliseconds duration
- */
- minutes(): number;
- /**
- * The minute part of the duration (always positive)
- * @return e.g. 2 for a -01:02:03.400 duration
- */
- minute(): number;
- /**
- * The entire duration in hours (negative or positive, fractional)
- * @return e.g. 1.5 for a 5400000 milliseconds duration
- */
- hours(): number;
- /**
- * The hour part of the duration (always positive).
- * Note that this part can exceed 23 hours, because for
- * now, we do not have a days() function
- * @return e.g. 25 for a -25:02:03.400 duration
- */
- wholeHours(): number;
- /**
- * Sign
- * @return "-" if the duration is negative
- */
- sign(): string;
- /**
- * @return True iff (this < other)
- */
- lessThan(other: Duration): boolean;
- /**
- * @return True iff this and other represent the same time duration
- */
- equals(other: Duration): boolean;
- /**
- * @return True iff this > other
- */
- greaterThan(other: Duration): boolean;
- /**
- * @return The minimum (most negative) of this and other
- */
- min(other: Duration): Duration;
- /**
- * @return The maximum (most positive) of this and other
- */
- max(other: Duration): Duration;
- /**
- * Multiply with a fixed number.
- * @return a new Duration of (this * value)
- */
- multiply(value: number): Duration;
- /**
- * Divide by a fixed number.
- * @return a new Duration of (this / value)
- */
- divide(value: number): Duration;
- /**
- * Add a duration.
- * @return a new Duration of (this + value)
- */
- add(value: Duration): Duration;
- /**
- * Subtract a duration.
- * @return a new Duration of (this - value)
- */
- sub(value: Duration): Duration;
- /**
- * String in [-]hh:mm:ss.nnn notation. All fields are
- * always present except the sign.
- */
- toFullString(): string;
- /**
- * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are
- * added as necessary
- */
- toString(): string;
- /**
- * Used by util.inspect()
- */
- inspect(): string;
- }
-}
-
-declare module '__timezonecomplete/javascript' {
- /**
- * Indicates how a Date object should be interpreted.
- * Either we can take getYear(), getMonth() etc for our field
- * values, or we can take getUTCYear(), getUtcMonth() etc to do that.
- */
- export enum DateFunctions {
- /**
- * Use the Date.getFullYear(), Date.getMonth(), ... functions.
- */
- Get = 0,
- /**
- * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions.
- */
- GetUTC = 1,
- }
-}
-
-declare module '__timezonecomplete/period' {
- import basics = require("__timezonecomplete/basics");
- import datetime = require("__timezonecomplete/datetime");
- /**
- * Specifies how the period should repeat across the day
- * during DST changes.
- */
- export enum PeriodDst {
- /**
- * Keep repeating in similar intervals measured in UTC,
- * unaffected by Daylight Saving Time.
- * E.g. a repetition of one hour will take one real hour
- * every time, even in a time zone with DST.
- * Leap seconds, leap days and month length
- * differences will still make the intervals different.
- */
- RegularIntervals = 0,
- /**
- * Ensure that the time at which the intervals occur stay
- * at the same place in the day, local time. So e.g.
- * a period of one day, starting at 8:05AM Europe/Amsterdam time
- * will always start at 8:05 Europe/Amsterdam. This means that
- * in UTC time, some intervals will be 25 hours and some
- * 23 hours during DST changes.
- * Another example: an hourly interval will be hourly in local time,
- * skipping an hour in UTC for a DST backward change.
- */
- RegularLocalTime = 1,
- }
- /**
- * Convert a PeriodDst to a string: "regular intervals" or "regular local time"
- */
- export function periodDstToString(p: PeriodDst): string;
- /**
- * Repeating time period: consists of a starting point and
- * a time length. This class accounts for leap seconds and leap days.
- */
- export class Period {
- /**
- * Constructor
- * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour,
- * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not.
- * This is due to the enormous processing power required by these cases. They are not
- * implemented and you will get an assert.
- *
- * @param start The start of the period. If the period is in Months or Years, and
- * the day is 29 or 30 or 31, the results are maximised to end-of-month.
- * @param amount The amount of units.
- * @param unit The unit.
- * @param dst Specifies how to handle Daylight Saving Time. Not relevant
- * if the time zone of the start datetime does not have DST.
- */
- constructor(start: datetime.DateTime, amount: number, unit: basics.TimeUnit, dst: PeriodDst);
- /**
- * The start date
- */
- start(): datetime.DateTime;
- /**
- * The amount of units
- */
- amount(): number;
- /**
- * The unit
- */
- unit(): basics.TimeUnit;
- /**
- * The dst handling mode
- */
- dst(): PeriodDst;
- /**
- * The first occurrence of the period greater than
- * the given date. The given date need not be at a period boundary.
- * Pre: the fromdate and startdate must either both have timezones or not
- * @param fromDate: the date after which to return the next date
- * @return the first date matching the period after fromDate, given
- * in the same zone as the fromDate.
- */
- findFirst(fromDate: datetime.DateTime): datetime.DateTime;
- /**
- * Returns the next timestamp in the period. The given timestamp must
- * be at a period boundary, otherwise the answer is incorrect.
- * This function has MUCH better performance than findFirst.
- * Returns the datetime "count" times away from the given datetime.
- * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one.
- * @param count Optional, must be >= 1 and whole.
- * @return (prev + count * period), in the same timezone as prev.
- */
- findNext(prev: datetime.DateTime, count?: number): datetime.DateTime;
- /**
- * Returns an ISO duration string e.g.
- * 2014-01-01T12:00:00.000+01:00/P1H
- * 2014-01-01T12:00:00.000+01:00/PT1M (one minute)
- * 2014-01-01T12:00:00.000+01:00/P1M (one month)
- */
- toIsoString(): string;
- /**
- * A string representation e.g.
- * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals".
- */
- toString(): string;
- /**
- * Used by util.inspect()
- */
- inspect(): string;
- }
-}
-
-declare module '__timezonecomplete/timesource' {
- /**
- * For testing purposes, we often need to manipulate what the current
- * time is. This is an interface for a custom time source object
- * so in tests you can use a custom time source.
- */
- export interface TimeSource {
- /**
- * Return the current date+time as a javascript Date object
- */
- now(): Date;
- }
- /**
- * Default time source, returns actual time
- */
- export class RealTimeSource implements TimeSource {
- now(): Date;
- }
-}
-
-declare module '__timezonecomplete/timezone' {
- import javascript = require("__timezonecomplete/javascript");
- /**
- * The type of time zone
- */
- export enum TimeZoneKind {
- /**
- * Local time offset as determined by JavaScript Date class.
- */
- Local = 0,
- /**
- * Fixed offset from UTC, without DST.
- */
- Offset = 1,
- /**
- * IANA timezone managed through Olsen TZ database. Includes
- * DST if applicable.
- */
- Proper = 2,
- }
- /**
- * Option for TimeZone#normalizeLocal()
- */
- export enum NormalizeOption {
- /**
- * Normalize non-existing times by ADDING the DST offset
- */
- Up = 0,
- /**
- * Normalize non-existing times by SUBTRACTING the DST offset
- */
- Down = 1,
- }
- /**
- * Time zone. The object is immutable because it is cached:
- * requesting a time zone twice yields the very same object.
- * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(),
- * i.e. offset 90 means +01:30.
- *
- * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date,
- * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST
- * applied depending on the time zone rules.
- */
- export class TimeZone {
- /**
- * The local time zone for a given date. Note that
- * the time zone varies with the date: amsterdam time for
- * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00
- */
- static local(): TimeZone;
- /**
- * The UTC time zone.
- */
- 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
- */
- 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
- */
- static zone(s: string): TimeZone;
- /**
- * Do not use this constructor, use the static
- * TimeZone.zone() method instead.
- * @param name NORMALIZED name, assumed to be correct
- */
- constructor(name: string);
- /**
- * 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;
- /**
- * The kind of time zone (Local/Offset/Proper)
- */
- kind(): TimeZoneKind;
- /**
- * Equality operator. Maps zero offsets and different names for UTC onto
- * each other. Other time zones are not mapped onto each other.
- */
- equals(other: TimeZone): boolean;
- /**
- * Is this zone equivalent to UTC?
- */
- isUtc(): boolean;
- /**
- * Does this zone have Daylight Saving Time at all?
- */
- 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
- * @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;
- /**
- * Calculate timezone offset from a zone-local time (NOT 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
- * @return the offset of this time zone with respect to UTC at the given time, in minutes.
- */
- offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
- /**
- * Note: will be removed in version 2.0.0
- *
- * Convenience function, takes values from a Javascript Date
- * Calls offsetForUtc() with the contents of the date
- *
- * @param date: the date
- * @param funcs: the set of functions to use: get() or getUTC()
- */
- offsetForUtcDate(date: Date, funcs: javascript.DateFunctions): number;
- /**
- * Note: will be removed in version 2.0.0
- *
- * Convenience function, takes values from a Javascript Date
- * Calls offsetForUtc() with the contents of the date
- *
- * @param date: the date
- * @param funcs: the set of functions to use: get() or getUTC()
- */
- offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number;
- /**
- * Normalizes non-existing local times by adding a forward offset change.
- * During a forward standard offset change or DST offset change, some amount of
- * local time is skipped. Therefore, this amount of local time does not exist.
- * This function adds the amount of forward change to any non-existing time. After all,
- * this is probably what the user meant.
- *
- * @param localUnixMillis Unix timestamp in zone time
- * @param opt (optional) Round up or down? Default: up
- *
- * @returns Unix timestamp in zone time, normalized.
- */
- normalizeZoneTime(localUnixMillis: number, opt?: NormalizeOption): number;
- /**
- * The time zone identifier (normalized).
- * Either "localtime", IANA name, or "+hh:mm" offset.
- */
- toString(): string;
- /**
- * Used by util.inspect()
- */
- inspect(): string;
- /**
- * Convert an offset number into an offset string
- * @param offset The offset in minutes from UTC e.g. 90 minutes
- * @return the offset in ISO notation "+01:30" for +90 minutes
- */
- static offsetToString(offset: number): string;
- /**
- * String to offset conversion.
- * @param s Formats: "-01:00", "-0100", "-01", "Z"
- * @return offset w.r.t. UTC in minutes
- */
- static stringToOffset(s: string): number;
- }
-}
-
+// Type definitions for timezonecomplete 1.4.6
+// Project: https://github.com/SpiritIT/timezonecomplete
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+// Generated by dts-bundle v0.2.0
+
+declare module 'timezonecomplete-1.4.6' {
+ import basics = require("__timezonecomplete/basics");
+ export import TimeUnit = basics.TimeUnit;
+ export import WeekDay = basics.WeekDay;
+ export import isLeapYear = basics.isLeapYear;
+ export import daysInMonth = basics.daysInMonth;
+ export import daysInYear = basics.daysInYear;
+ export import dayOfYear = basics.dayOfYear;
+ export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth;
+ export import weekDayOnOrAfter = basics.weekDayOnOrAfter;
+ export import weekDayOnOrBefore = basics.weekDayOnOrBefore;
+ import datetime = require("__timezonecomplete/datetime");
+ export import DateTime = datetime.DateTime;
+ import duration = require("__timezonecomplete/duration");
+ export import Duration = duration.Duration;
+ import javascript = require("__timezonecomplete/javascript");
+ export import DateFunctions = javascript.DateFunctions;
+ import period = require("__timezonecomplete/period");
+ export import Period = period.Period;
+ export import PeriodDst = period.PeriodDst;
+ export import periodDstToString = period.periodDstToString;
+ import timesource = require("__timezonecomplete/timesource");
+ export import TimeSource = timesource.TimeSource;
+ export import RealTimeSource = timesource.RealTimeSource;
+ import timezone = require("__timezonecomplete/timezone");
+ export import NormalizeOption = timezone.NormalizeOption;
+ export import TimeZoneKind = timezone.TimeZoneKind;
+ export import TimeZone = timezone.TimeZone;
+}
+
+declare module '__timezonecomplete/basics' {
+ import javascript = require("__timezonecomplete/javascript");
+ /**
+ * Day-of-week. Note the enum values correspond to JavaScript day-of-week:
+ * Sunday = 0, Monday = 1 etc
+ */
+ export enum WeekDay {
+ Sunday = 0,
+ Monday = 1,
+ Tuesday = 2,
+ Wednesday = 3,
+ Thursday = 4,
+ Friday = 5,
+ Saturday = 6,
+ }
+ /**
+ * Time units
+ */
+ export enum TimeUnit {
+ Second = 0,
+ Minute = 1,
+ Hour = 2,
+ Day = 3,
+ Week = 4,
+ Month = 5,
+ Year = 6,
+ }
+ /**
+ * @return True iff the given year is a leap year.
+ */
+ export function isLeapYear(year: number): boolean;
+ /**
+ * The days in a given year
+ */
+ export function daysInYear(year: number): number;
+ /**
+ * @param year The full year
+ * @param month The month 1-12
+ * @return The number of days in the given month
+ */
+ export function daysInMonth(year: number, month: number): number;
+ /**
+ * Returns the day of the year of the given date [0..365]. January first is 0.
+ *
+ * @param year The year e.g. 1986
+ * @param month Month 1-12
+ * @param day Day of month 1-31
+ */
+ export function dayOfYear(year: number, month: number, day: number): number;
+ /**
+ * Returns the last 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 last occurrence of the week day in the month
+ */
+ export function lastWeekDayOfMonth(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.
+ */
+ export function weekDayOnOrAfter(year: number, month: number, day: 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.
+ */
+ export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number;
+ /**
+ * Convert a unix milli timestamp into a TimeT structure.
+ * This does NOT take leap seconds into account.
+ */
+ export function unixToTimeNoLeapSecs(unixMillis: number): TimeStruct;
+ /**
+ * Convert a year, month, day etc into a unix milli timestamp.
+ * This does NOT take leap seconds into account.
+ *
+ * @param year Year e.g. 1970
+ * @param month Month 1-12
+ * @param day Day 1-31
+ * @param hour Hour 0-23
+ * @param minute Minute 0-59
+ * @param second Second 0-59 (no leap seconds)
+ * @param milli Millisecond 0-999
+ */
+ export function timeToUnixNoLeapSecs(year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, milli?: number): number;
+ /**
+ * Convert a TimeT structure into a unix milli timestamp.
+ * This does NOT take leap seconds into account.
+ */
+ export function timeToUnixNoLeapSecs(tm: TimeStruct): number;
+ /**
+ * Return the day-of-week.
+ * This does NOT take leap seconds into account.
+ */
+ export function weekDayNoLeapSecs(unixMillis: number): WeekDay;
+ /**
+ * Basic representation of a date and time
+ */
+ export class TimeStruct {
+ /**
+ * Year, 1970-...
+ */
+ year: number;
+ /**
+ * Month 1-12
+ */
+ month: number;
+ /**
+ * Day of month, 1-31
+ */
+ day: number;
+ /**
+ * Hour 0-23
+ */
+ hour: number;
+ /**
+ * Minute 0-59
+ */
+ minute: number;
+ /**
+ * Seconds, 0-59
+ */
+ second: number;
+ /**
+ * Milliseconds 0-999
+ */
+ milli: number;
+ /**
+ * Create a TimeStruct from a number of unix milliseconds
+ */
+ static fromUnix(unixMillis: number): TimeStruct;
+ /**
+ * Create a TimeStruct from a JavaScript date
+ *
+ * @param d The date
+ * @param df Which functions to take (getX() or getUTCX())
+ */
+ static fromDate(d: Date, df: javascript.DateFunctions): TimeStruct;
+ /**
+ * Returns a TimeStruct from an ISO 8601 string WITHOUT time zone
+ */
+ static fromString(s: string): TimeStruct;
+ /**
+ * Constructor
+ *
+ * @param year Year e.g. 1970
+ * @param month Month 1-12
+ * @param day Day 1-31
+ * @param hour Hour 0-23
+ * @param minute Minute 0-59
+ * @param second Second 0-59 (no leap seconds)
+ * @param milli Millisecond 0-999
+ */
+ constructor(/**
+ * Year, 1970-...
+ */
+ year?: number, /**
+ * Month 1-12
+ */
+ month?: number, /**
+ * Day of month, 1-31
+ */
+ day?: number, /**
+ * Hour 0-23
+ */
+ hour?: number, /**
+ * Minute 0-59
+ */
+ minute?: number, /**
+ * Seconds, 0-59
+ */
+ second?: number, /**
+ * Milliseconds 0-999
+ */
+ milli?: number);
+ /**
+ * Validate a TimeStruct, returns false if invalid.
+ */
+ validate(): boolean;
+ /**
+ * The day-of-year 0-365
+ */
+ yearDay(): number;
+ /**
+ * Returns this time as a unix millisecond timestamp
+ * Does NOT take leap seconds into account.
+ */
+ toUnixNoLeapSecs(): number;
+ /**
+ * Deep equals
+ */
+ equals(other: TimeStruct): boolean;
+ /**
+ * < operator
+ */
+ lessThan(other: TimeStruct): boolean;
+ clone(): TimeStruct;
+ valueOf(): number;
+ /**
+ * ISO 8601 string YYYY-MM-DDThh:mm:ss.nnn
+ */
+ toString(): string;
+ inspect(): string;
+ }
+}
+
+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 timezone = require("__timezonecomplete/timezone");
+ /**
+ * DateTime class which is time zone-aware
+ * and which can be mocked for testing purposes.
+ */
+ export class DateTime {
+ /**
+ * Actual time source in use. Setting this property allows to
+ * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc()
+ * use this property for obtaining the current time.
+ */
+ static timeSource: timesource.TimeSource;
+ /**
+ * Current date+time in local time (derived from DateTime.timeSource.now()).
+ */
+ static nowLocal(): DateTime;
+ /**
+ * Current date+time in UTC time (derived from DateTime.timeSource.now()).
+ */
+ static nowUtc(): DateTime;
+ /**
+ * Current date+time in the given time zone (derived from DateTime.timeSource.now()).
+ * @param timeZone The desired time zone.
+ */
+ static now(timeZone: timezone.TimeZone): DateTime;
+ /**
+ * Constructor. Creates current time in local timezone.
+ */
+ constructor();
+ /**
+ * Constructor
+ * Non-existing local times are normalized by rounding up to the next DST offset.
+ *
+ * @param isoString String in ISO 8601 format. Instead of ISO time zone,
+ * it may include a space and then and IANA time zone.
+ * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date)
+ * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time)
+ * or "2007-04-05T12:30:40.500Z" (UTC)
+ * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable)
+ * @param timeZone if given, the date in the string is assumed to be in this time zone.
+ * Note that it is NOT CONVERTED to the time zone. Useful
+ * for strings without a time zone
+ */
+ constructor(isoString: string, timeZone?: timezone.TimeZone);
+ /**
+ * Constructor. You provide a date, then you say whether to take the
+ * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods,
+ * and then you state which time zone that date is in.
+ * Non-existing local times are normalized by rounding up to the next DST offset.
+ * Note that the Date class has bugs and inconsistencies when constructing them with times around
+ * DST changes.
+ *
+ * @param date A date object.
+ * @param getters Specifies which set of Date getters contains the date in the given time zone: the
+ * Date.getXxx() methods or the Date.getUTCXxx() methods.
+ * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates)
+ */
+ constructor(date: Date, getFuncs: javascript.DateFunctions, timeZone?: timezone.TimeZone);
+ /**
+ * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges.
+ * Use the add(duration) or sub(duration) for arithmetic.
+ * @param year The full year (e.g. 2014)
+ * @param month The month [1-12] (note this deviates from JavaScript Date)
+ * @param day The day of the month [1-31]
+ * @param hour The hour of the day [0-24)
+ * @param minute The minute of the hour [0-59]
+ * @param second The second of the minute [0-59]
+ * @param millisecond The millisecond of the second [0-999]
+ * @param timeZone The time zone, or null (for unaware dates)
+ */
+ constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: timezone.TimeZone);
+ /**
+ * Constructor
+ * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000
+ * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC).
+ */
+ constructor(unixTimestamp: number, timeZone?: timezone.TimeZone);
+ /**
+ * @return a copy of this object
+ */
+ clone(): DateTime;
+ /**
+ * @return The time zone that the date is in. May be null for unaware dates.
+ */
+ zone(): timezone.TimeZone;
+ /**
+ * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates.
+ */
+ offset(): number;
+ /**
+ * @return The full year e.g. 2014
+ */
+ year(): number;
+ /**
+ * @return The month 1-12 (note this deviates from JavaScript Date)
+ */
+ month(): number;
+ /**
+ * @return The day of the month 1-31
+ */
+ day(): number;
+ /**
+ * @return The hour 0-23
+ */
+ hour(): number;
+ /**
+ * @return the minutes 0-59
+ */
+ minute(): number;
+ /**
+ * @return the seconds 0-59
+ */
+ second(): number;
+ /**
+ * @return the milliseconds 0-999
+ */
+ millisecond(): number;
+ /**
+ * @return the day-of-week (the enum values correspond to JavaScript
+ * week day numbers)
+ */
+ weekDay(): basics.WeekDay;
+ /**
+ * @return Milliseconds since 1970-01-01T00:00:00.000Z
+ */
+ unixUtcMillis(): number;
+ /**
+ * @return The full year e.g. 2014
+ */
+ utcYear(): number;
+ /**
+ * @return The UTC month 1-12 (note this deviates from JavaScript Date)
+ */
+ utcMonth(): number;
+ /**
+ * @return The UTC day of the month 1-31
+ */
+ utcDay(): number;
+ /**
+ * @return The UTC hour 0-23
+ */
+ utcHour(): number;
+ /**
+ * @return The UTC minutes 0-59
+ */
+ utcMinute(): number;
+ /**
+ * @return The UTC seconds 0-59
+ */
+ utcSecond(): number;
+ /**
+ * @return The UTC milliseconds 0-999
+ */
+ utcMillisecond(): number;
+ /**
+ * @return the UTC day-of-week (the enum values correspond to JavaScript
+ * week day numbers)
+ */
+ utcWeekDay(): basics.WeekDay;
+ /**
+ * Convert this date to the given time zone (in-place).
+ * Throws if this date does not have a time zone.
+ * @return this (for chaining)
+ */
+ convert(zone?: timezone.TimeZone): DateTime;
+ /**
+ * Returns this date converted to the given time zone.
+ * Unaware dates can only be converted to unaware dates (clone)
+ * Converting an unaware date to an aware date throws an exception. Use the constructor
+ * if you really need to do that.
+ *
+ * @param zone The new time zone. This may be null to create unaware date.
+ * @return The converted date
+ */
+ toZone(zone?: timezone.TimeZone): DateTime;
+ /**
+ * Convert to JavaScript date with the zone time in the getX() methods.
+ * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct.
+ * This is because Date calculates getUTCX() from getX() applying local time zone.
+ */
+ toDate(): Date;
+ /**
+ * Add a time duration relative to UTC. Note that this simply adds a number
+ * of milliseconds to UTC and converts back to zone(),
+ * There is not DST handling.
+ * @return this + duration
+ */
+ add(duration: duration.Duration): DateTime;
+ /**
+ * Add an amount of time relative to UTC, as regularly as possible.
+ *
+ * Adding e.g. 1 hour will increment the utcHour() field, adding 1 month
+ * increments the utcMonth() field.
+ * Adding an amount of units leaves lower units intact. E.g.
+ * adding a month will leave the day() field untouched if possible.
+ *
+ * Note adding Months or Years will clamp the date to the end-of-month if
+ * the start date was at the end of a month, i.e. contrary to JavaScript
+ * Date#setUTCMonth() it will not overflow into the next month
+ *
+ * In case of DST changes, the utc time fields are still untouched but local
+ * time fields may shift.
+ */
+ add(amount: number, unit: basics.TimeUnit): DateTime;
+ /**
+ * Add an amount of time to the zone time, as regularly as possible.
+ *
+ * Adding e.g. 1 hour will increment the hour() field of the zone
+ * date by one. In case of DST changes, the time fields may additionally
+ * increase by the DST offset, if a non-existing local time would
+ * be reached otherwise.
+ *
+ * Adding a unit of time will leave lower-unit fields intact, unless the result
+ * would be a non-existing time. Then an extra DST offset is added.
+ *
+ * Note adding Months or Years will clamp the date to the end-of-month if
+ * the start date was at the end of a month, i.e. contrary to JavaScript
+ * Date#setUTCMonth() it will not overflow into the next month
+ */
+ addLocal(amount: number, unit: basics.TimeUnit): DateTime;
+ /**
+ * Same as add(-1*duration);
+ */
+ sub(duration: duration.Duration): DateTime;
+ /**
+ * Same as add(-1*amount, unit);
+ */
+ sub(amount: number, unit: basics.TimeUnit): DateTime;
+ /**
+ * Same as addLocal(-1*amount, unit);
+ */
+ subLocal(amount: number, unit: basics.TimeUnit): DateTime;
+ /**
+ * Time difference between two DateTimes
+ * @return this - other
+ */
+ diff(other: DateTime): duration.Duration;
+ /**
+ * @return True iff (this < other)
+ */
+ lessThan(other: DateTime): boolean;
+ /**
+ * @return True iff (this <= other)
+ */
+ lessEqual(other: DateTime): boolean;
+ /**
+ * @return True iff this and other represent the same time in UTC
+ */
+ equals(other: DateTime): boolean;
+ /**
+ * @return True iff this and other represent the same time and
+ * have the same zone
+ */
+ identical(other: DateTime): boolean;
+ /**
+ * @return True iff this > other
+ */
+ greaterThan(other: DateTime): boolean;
+ /**
+ * @return True iff this >= other
+ */
+ greaterEqual(other: DateTime): boolean;
+ /**
+ * Proper ISO 8601 format string with any IANA zone converted to ISO offset
+ * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam
+ */
+ toIsoString(): string;
+ /**
+ * Modified ISO 8601 format string with IANA name if applicable.
+ * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam"
+ */
+ toString(): string;
+ /**
+ * Used by util.inspect()
+ */
+ inspect(): string;
+ /**
+ * Modified ISO 8601 format string in UTC without time zone info
+ */
+ toUtcString(): string;
+ }
+}
+
+declare module '__timezonecomplete/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:
+ * one hour is simply represented as 3600000 milliseconds.
+ */
+ export class Duration {
+ /**
+ * Construct a time duration
+ * @param n Number of hours
+ * @return A duration of n hours
+ */
+ static hours(n: number): Duration;
+ /**
+ * Construct a time duration
+ * @param n Number of minutes
+ * @return A duration of n minutes
+ */
+ static minutes(n: number): Duration;
+ /**
+ * Construct a time duration
+ * @param n Number of seconds
+ * @return A duration of n seconds
+ */
+ static seconds(n: number): Duration;
+ /**
+ * Construct a time duration
+ * @param n Number of milliseconds
+ * @return A duration of n milliseconds
+ */
+ static milliseconds(n: number): Duration;
+ /**
+ * Construct a time duration of 0
+ */
+ constructor();
+ /**
+ * Construct a time duration from a number of milliseconds
+ */
+ constructor(milliseconds: number);
+ /**
+ * Construct a time duration from a string in format
+ * [-]h[:m[:s[.n]]] e.g. -01:00:30.501
+ */
+ constructor(input: string);
+ /**
+ * @return another instance of Duration with the same value.
+ */
+ clone(): Duration;
+ /**
+ * The entire duration in milliseconds (negative or positive)
+ */
+ milliseconds(): number;
+ /**
+ * The millisecond part of the duration (always positive)
+ * @return e.g. 400 for a -01:02:03.400 duration
+ */
+ millisecond(): number;
+ /**
+ * The entire duration in seconds (negative or positive, fractional)
+ * @return e.g. 1.5 for a 1500 milliseconds duration
+ */
+ seconds(): number;
+ /**
+ * The second part of the duration (always positive)
+ * @return e.g. 3 for a -01:02:03.400 duration
+ */
+ second(): number;
+ /**
+ * The entire duration in minutes (negative or positive, fractional)
+ * @return e.g. 1.5 for a 90000 milliseconds duration
+ */
+ minutes(): number;
+ /**
+ * The minute part of the duration (always positive)
+ * @return e.g. 2 for a -01:02:03.400 duration
+ */
+ minute(): number;
+ /**
+ * The entire duration in hours (negative or positive, fractional)
+ * @return e.g. 1.5 for a 5400000 milliseconds duration
+ */
+ hours(): number;
+ /**
+ * The hour part of the duration (always positive).
+ * Note that this part can exceed 23 hours, because for
+ * now, we do not have a days() function
+ * @return e.g. 25 for a -25:02:03.400 duration
+ */
+ wholeHours(): number;
+ /**
+ * Sign
+ * @return "-" if the duration is negative
+ */
+ sign(): string;
+ /**
+ * @return True iff (this < other)
+ */
+ lessThan(other: Duration): boolean;
+ /**
+ * @return True iff this and other represent the same time duration
+ */
+ equals(other: Duration): boolean;
+ /**
+ * @return True iff this > other
+ */
+ greaterThan(other: Duration): boolean;
+ /**
+ * @return The minimum (most negative) of this and other
+ */
+ min(other: Duration): Duration;
+ /**
+ * @return The maximum (most positive) of this and other
+ */
+ max(other: Duration): Duration;
+ /**
+ * Multiply with a fixed number.
+ * @return a new Duration of (this * value)
+ */
+ multiply(value: number): Duration;
+ /**
+ * Divide by a fixed number.
+ * @return a new Duration of (this / value)
+ */
+ divide(value: number): Duration;
+ /**
+ * Add a duration.
+ * @return a new Duration of (this + value)
+ */
+ add(value: Duration): Duration;
+ /**
+ * Subtract a duration.
+ * @return a new Duration of (this - value)
+ */
+ sub(value: Duration): Duration;
+ /**
+ * String in [-]hh:mm:ss.nnn notation. All fields are
+ * always present except the sign.
+ */
+ toFullString(): string;
+ /**
+ * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are
+ * added as necessary
+ */
+ toString(): string;
+ /**
+ * Used by util.inspect()
+ */
+ inspect(): string;
+ }
+}
+
+declare module '__timezonecomplete/javascript' {
+ /**
+ * Indicates how a Date object should be interpreted.
+ * Either we can take getYear(), getMonth() etc for our field
+ * values, or we can take getUTCYear(), getUtcMonth() etc to do that.
+ */
+ export enum DateFunctions {
+ /**
+ * Use the Date.getFullYear(), Date.getMonth(), ... functions.
+ */
+ Get = 0,
+ /**
+ * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions.
+ */
+ GetUTC = 1,
+ }
+}
+
+declare module '__timezonecomplete/period' {
+ import basics = require("__timezonecomplete/basics");
+ import datetime = require("__timezonecomplete/datetime");
+ /**
+ * Specifies how the period should repeat across the day
+ * during DST changes.
+ */
+ export enum PeriodDst {
+ /**
+ * Keep repeating in similar intervals measured in UTC,
+ * unaffected by Daylight Saving Time.
+ * E.g. a repetition of one hour will take one real hour
+ * every time, even in a time zone with DST.
+ * Leap seconds, leap days and month length
+ * differences will still make the intervals different.
+ */
+ RegularIntervals = 0,
+ /**
+ * Ensure that the time at which the intervals occur stay
+ * at the same place in the day, local time. So e.g.
+ * a period of one day, starting at 8:05AM Europe/Amsterdam time
+ * will always start at 8:05 Europe/Amsterdam. This means that
+ * in UTC time, some intervals will be 25 hours and some
+ * 23 hours during DST changes.
+ * Another example: an hourly interval will be hourly in local time,
+ * skipping an hour in UTC for a DST backward change.
+ */
+ RegularLocalTime = 1,
+ }
+ /**
+ * Convert a PeriodDst to a string: "regular intervals" or "regular local time"
+ */
+ export function periodDstToString(p: PeriodDst): string;
+ /**
+ * Repeating time period: consists of a starting point and
+ * a time length. This class accounts for leap seconds and leap days.
+ */
+ export class Period {
+ /**
+ * Constructor
+ * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour,
+ * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not.
+ * This is due to the enormous processing power required by these cases. They are not
+ * implemented and you will get an assert.
+ *
+ * @param start The start of the period. If the period is in Months or Years, and
+ * the day is 29 or 30 or 31, the results are maximised to end-of-month.
+ * @param amount The amount of units.
+ * @param unit The unit.
+ * @param dst Specifies how to handle Daylight Saving Time. Not relevant
+ * if the time zone of the start datetime does not have DST.
+ */
+ constructor(start: datetime.DateTime, amount: number, unit: basics.TimeUnit, dst: PeriodDst);
+ /**
+ * The start date
+ */
+ start(): datetime.DateTime;
+ /**
+ * The amount of units
+ */
+ amount(): number;
+ /**
+ * The unit
+ */
+ unit(): basics.TimeUnit;
+ /**
+ * The dst handling mode
+ */
+ dst(): PeriodDst;
+ /**
+ * The first occurrence of the period greater than
+ * the given date. The given date need not be at a period boundary.
+ * Pre: the fromdate and startdate must either both have timezones or not
+ * @param fromDate: the date after which to return the next date
+ * @return the first date matching the period after fromDate, given
+ * in the same zone as the fromDate.
+ */
+ findFirst(fromDate: datetime.DateTime): datetime.DateTime;
+ /**
+ * Returns the next timestamp in the period. The given timestamp must
+ * be at a period boundary, otherwise the answer is incorrect.
+ * This function has MUCH better performance than findFirst.
+ * Returns the datetime "count" times away from the given datetime.
+ * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one.
+ * @param count Optional, must be >= 1 and whole.
+ * @return (prev + count * period), in the same timezone as prev.
+ */
+ findNext(prev: datetime.DateTime, count?: number): datetime.DateTime;
+ /**
+ * Returns an ISO duration string e.g.
+ * 2014-01-01T12:00:00.000+01:00/P1H
+ * 2014-01-01T12:00:00.000+01:00/PT1M (one minute)
+ * 2014-01-01T12:00:00.000+01:00/P1M (one month)
+ */
+ toIsoString(): string;
+ /**
+ * A string representation e.g.
+ * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals".
+ */
+ toString(): string;
+ /**
+ * Used by util.inspect()
+ */
+ inspect(): string;
+ }
+}
+
+declare module '__timezonecomplete/timesource' {
+ /**
+ * For testing purposes, we often need to manipulate what the current
+ * time is. This is an interface for a custom time source object
+ * so in tests you can use a custom time source.
+ */
+ export interface TimeSource {
+ /**
+ * Return the current date+time as a javascript Date object
+ */
+ now(): Date;
+ }
+ /**
+ * Default time source, returns actual time
+ */
+ export class RealTimeSource implements TimeSource {
+ now(): Date;
+ }
+}
+
+declare module '__timezonecomplete/timezone' {
+ import javascript = require("__timezonecomplete/javascript");
+ /**
+ * The type of time zone
+ */
+ export enum TimeZoneKind {
+ /**
+ * Local time offset as determined by JavaScript Date class.
+ */
+ Local = 0,
+ /**
+ * Fixed offset from UTC, without DST.
+ */
+ Offset = 1,
+ /**
+ * IANA timezone managed through Olsen TZ database. Includes
+ * DST if applicable.
+ */
+ Proper = 2,
+ }
+ /**
+ * Option for TimeZone#normalizeLocal()
+ */
+ export enum NormalizeOption {
+ /**
+ * Normalize non-existing times by ADDING the DST offset
+ */
+ Up = 0,
+ /**
+ * Normalize non-existing times by SUBTRACTING the DST offset
+ */
+ Down = 1,
+ }
+ /**
+ * Time zone. The object is immutable because it is cached:
+ * requesting a time zone twice yields the very same object.
+ * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(),
+ * i.e. offset 90 means +01:30.
+ *
+ * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date,
+ * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST
+ * applied depending on the time zone rules.
+ */
+ export class TimeZone {
+ /**
+ * The local time zone for a given date. Note that
+ * the time zone varies with the date: amsterdam time for
+ * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00
+ */
+ static local(): TimeZone;
+ /**
+ * The UTC time zone.
+ */
+ 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
+ */
+ 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
+ */
+ static zone(s: string): TimeZone;
+ /**
+ * Do not use this constructor, use the static
+ * TimeZone.zone() method instead.
+ * @param name NORMALIZED name, assumed to be correct
+ */
+ constructor(name: string);
+ /**
+ * 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;
+ /**
+ * The kind of time zone (Local/Offset/Proper)
+ */
+ kind(): TimeZoneKind;
+ /**
+ * Equality operator. Maps zero offsets and different names for UTC onto
+ * each other. Other time zones are not mapped onto each other.
+ */
+ equals(other: TimeZone): boolean;
+ /**
+ * Is this zone equivalent to UTC?
+ */
+ isUtc(): boolean;
+ /**
+ * Does this zone have Daylight Saving Time at all?
+ */
+ 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
+ * @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;
+ /**
+ * Calculate timezone offset from a zone-local time (NOT 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
+ * @return the offset of this time zone with respect to UTC at the given time, in minutes.
+ */
+ offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number;
+ /**
+ * Note: will be removed in version 2.0.0
+ *
+ * Convenience function, takes values from a Javascript Date
+ * Calls offsetForUtc() with the contents of the date
+ *
+ * @param date: the date
+ * @param funcs: the set of functions to use: get() or getUTC()
+ */
+ offsetForUtcDate(date: Date, funcs: javascript.DateFunctions): number;
+ /**
+ * Note: will be removed in version 2.0.0
+ *
+ * Convenience function, takes values from a Javascript Date
+ * Calls offsetForUtc() with the contents of the date
+ *
+ * @param date: the date
+ * @param funcs: the set of functions to use: get() or getUTC()
+ */
+ offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number;
+ /**
+ * Normalizes non-existing local times by adding a forward offset change.
+ * During a forward standard offset change or DST offset change, some amount of
+ * local time is skipped. Therefore, this amount of local time does not exist.
+ * This function adds the amount of forward change to any non-existing time. After all,
+ * this is probably what the user meant.
+ *
+ * @param localUnixMillis Unix timestamp in zone time
+ * @param opt (optional) Round up or down? Default: up
+ *
+ * @returns Unix timestamp in zone time, normalized.
+ */
+ normalizeZoneTime(localUnixMillis: number, opt?: NormalizeOption): number;
+ /**
+ * The time zone identifier (normalized).
+ * Either "localtime", IANA name, or "+hh:mm" offset.
+ */
+ toString(): string;
+ /**
+ * Used by util.inspect()
+ */
+ inspect(): string;
+ /**
+ * Convert an offset number into an offset string
+ * @param offset The offset in minutes from UTC e.g. 90 minutes
+ * @return the offset in ISO notation "+01:30" for +90 minutes
+ */
+ static offsetToString(offset: number): string;
+ /**
+ * String to offset conversion.
+ * @param s Formats: "-01:00", "-0100", "-01", "Z"
+ * @return offset w.r.t. UTC in minutes
+ */
+ static stringToOffset(s: string): number;
+ }
+}
+
diff --git a/tspromise/tspromise-tests.ts b/tspromise/tspromise-tests.ts
index 79903f0ce..fcb52212a 100644
--- a/tspromise/tspromise-tests.ts
+++ b/tspromise/tspromise-tests.ts
@@ -1,21 +1,21 @@
-///
-
-import Promise = require('tspromise');
-
-var MyFuncFunc = Promise.async((a: boolean, b: number) => {
- console.log('[a] ' + a);
- yield(Promise.waitAsync(1000));
- console.log('[b]' + b);
-});
-
-MyFuncFunc(true, 10);
-
-Promise.all([Promise.waitAsync(10), Promise.waitAsync(20)]).then(() => {
- return new Promise((resolve, reject) => {
- resolve('test');
- });
-}).then(() => {
- throw (new Error());
-}).catch((e) => {
- console.log(e.message);
+///
+
+import Promise = require('tspromise');
+
+var MyFuncFunc = Promise.async((a: boolean, b: number) => {
+ console.log('[a] ' + a);
+ yield(Promise.waitAsync(1000));
+ console.log('[b]' + b);
+});
+
+MyFuncFunc(true, 10);
+
+Promise.all([Promise.waitAsync(10), Promise.waitAsync(20)]).then(() => {
+ return new Promise((resolve, reject) => {
+ resolve('test');
+ });
+}).then(() => {
+ throw (new Error());
+}).catch((e) => {
+ console.log(e.message);
});
\ No newline at end of file
diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts
index 1044fe3bf..3c8495f86 100644
--- a/typeahead/typeahead-tests.ts
+++ b/typeahead/typeahead-tests.ts
@@ -6,84 +6,50 @@
//
declare var Hogan: string;
-// Countries
-// Prefetches data, stores it in localStorage, and searches it on the client
-$('.example-countries .typeahead').typeahead({
- name: 'countries',
- prefetch: '../data/countries.json',
- limit: 10
+var substringMatcher = function (strs: any) {
+ return function findMatches(q: any, cb: any) {
+ var matches: any, substrRegex: any;
+
+ // an array that will be populated with substring matches
+ matches = [];
+
+ // regex used to determine if a string contains the substring `q`
+ substrRegex = new RegExp(q, 'i');
+
+ // iterate through the pool of strings and for any string that
+ // contains the substring `q`, add it to the `matches` array
+ $.each(strs, function (i, str) {
+ if (substrRegex.test(str)) {
+ // the typeahead jQuery plugin expects suggestions to a
+ // JavaScript object, refer to typeahead docs for more info
+ matches.push({ value: str });
+ }
});
-// Open Source Projects by Twitter
-// Defines a custom template and template engine for rendering suggestions
-$('.example-twitter-oss .typeahead').typeahead({
- name: 'twitter-oss',
- prefetch: '../data/repos.json',
- template: [
- '{{language}}
',
- '{{name}}
',
- '{{description}}
'
- ].join(''),
- engine: Hogan
-});
+ cb(matches);
+ };
+};
-// Arabic Phrases
-// Hardcoded list showing Right - To - Left(RTL) support
-$('.example-arabic .typeahead').typeahead({
- name: 'arabic',
- local: [
- "الإنجليزية",
- "نعم",
- "لا",
- "مرحبا",
- "کيف الحال؟",
- "أهلا",
- "مع السلامة",
- "لا أتكلم العربية",
- "لا أفهم",
- "أنا جائع"
- ]
-});
+var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
+ 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
+ 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
+ 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
+ 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
+ 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
+ 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
+ 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
+ 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
+];
-// NBA and NHL Teams
-// Two datasets that are prefetched, stored, and searched on the client
-$('.example-sports .typeahead').typeahead([
- {
- name: 'nba-teams',
- prefetch: '../data/nba.json',
- header: 'NBA Teams
'
- },
- {
- name: 'nhl-teams',
- prefetch: '../data/nhl.json',
- header: 'NHL Teams
'
- }
-]);
-
-// Best Picture Winners
-// Prefetches some data then relies on remote requests for suggestions when prefetched data is insufficient
-$('.example-films .typeahead').typeahead([
- {
- name: 'best-picture-winners',
- remote: '../data/films/queries/%QUERY.json',
- prefetch: '../data/films/post_1960.json',
- template: '{{value}} – {{year}}
',
- engine: Hogan
- }
-]);
-
-// Countries - Modified the first test here to add options
-// Specifies options to display hint with a highlight and adds a minimum length restriction for search
-// Prefetches data, stores it in localStorage, and searches it on the client
-$('.example-countries .typeahead').typeahead({
+$('#the-basics .typeahead').typeahead({
hint: true,
highlight: true,
- minLength: 2
+ minLength: 1
},
{
- name: 'countries',
- prefetch: '../data/countries.json',
- limit: 10
+ name: 'states',
+ displayKey: 'value',
+ source: substringMatcher(states)
});
module valueTest {
diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts
index bb8aaf31d..c2d50dfc4 100644
--- a/typeahead/typeahead.d.ts
+++ b/typeahead/typeahead.d.ts
@@ -1,53 +1,71 @@
-// Type definitions for typeahead.js 0.9.3
+// Type definitions for typeahead.js 0.10.4
// Project: http://twitter.github.io/typeahead.js/
-// Definitions by: Ivaylo Gochkov
+// Definitions by: Ivaylo Gochkov , Gidon Junge
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///
interface JQuery {
- /**
- * Turns an input[type="text"] element into a typeahead.
- *
- * @constructor
- * @param dataset Single dataset
- */
- typeahead(dataset: Twitter.Typeahead.Dataset): JQuery;
-
- /**
- * Turns an input[type="text"] element into a typeahead.
- *
- * @constructor
- * @param dataset Array of datasets
- */
- typeahead(datasets: Twitter.Typeahead.Dataset[]): JQuery;
/**
* Destroys previously initialized typeaheads. This entails reverting
* DOM modifications and removing event handlers.
- *
- * @constructor
+ *
+ * @constructor
* @param methodName Method 'destroy'
- */
+ */
typeahead(methodName: 'destroy'): JQuery;
/**
- * Sets the current query of the typeahead. This is always preferable to
- * using $("input.typeahead").val(query), which will result in unexpected
- * behavior. To clear the query, simply set it to an empty string.
+ * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible.
+ * The menu is only visible when it is open and has content.
*
* @constructor
- * @param methodName Method 'setQuery'
- * @param query The query to be set
+ * @param methodName Method 'open'
*/
- typeahead(methodName: 'setQuery', query: string): JQuery;
+ typeahead(methodName: 'open'): JQuery;
/**
- * Accommodates the destroy and setQuery overloads.
+ * Closes the dropdown menu of typeahead.
+ *
+ * @constructor
+ * @param methodName Method 'close'
+ */
+ typeahead(methodName: 'close'): JQuery;
+
+ /**
+ * Returns the current value of the typeahead.
+ * The value is the text the user has entered into the input element.
*
* @constructor
- * @param methodName Method name ('destroy' or 'setQuery')
- * @param query The query to be set in case method 'setQuery' is used.
+ * @param methodName Method 'val'
+ */
+ typeahead(methodName: 'val'): string;
+
+ /**
+ * Sets the value of the typeahead. This should be used in place of jQuery#val.
+ *
+ * @constructor
+ * @param methodName Method 'val'
+ * @param query The value to be set
+ */
+ typeahead(methodName: 'val', val: string): JQuery;
+
+ /**
+ * Accommodates the val overload.
+ *
+ * @constructor
+ * @param methodName Method name ('val')
+ */
+ typeahead(methodName: string): string;
+
+
+ /**
+ * Accommodates multiple overloads.
+ *
+ * @constructor
+ * @param methodName Method name
+ * @param query The query to be set in case method 'val' is used.
*/
typeahead(methodName: string, query: string): JQuery;
@@ -57,20 +75,19 @@ interface JQuery {
*
* @constructor
* @param options ('hint' or 'highlight' or 'minLength' all of which are optional)
- * @param dataset Array of datasets
+ * @param datasets Array of datasets
*/
- typeahead(options: Twitter.Typeahead.Options, dataset: Twitter.Typeahead.Dataset): JQuery;
+ typeahead(options: Twitter.Typeahead.Options, datasets: Twitter.Typeahead.Dataset[]): JQuery;
/**
- * Returns the current value of the typeahead. The value is the text the user has entered into the input element.
+ * Accomodates specifying options such as hint and highlight.
+ * This is in correspondence to the examples mentioned in http://twitter.github.io/typeahead.js/examples/
+ *
+ * @constructor
+ * @param options ('hint' or 'highlight' or 'minLength' all of which are optional)
+ * @param datasets One or more datasets passed in as arguments.
*/
- typeahead(methodName: 'val'): string;
- typeahead(methodName: string): string;
-
- /**
- * Sets the value of the typeahead. This should be used in place of jQuery#val.
- */
- typeahead(methodName: 'val', value: string): JQuery;
+ typeahead(options: Twitter.Typeahead.Options, ... datasets: Twitter.Typeahead.Dataset[]): JQuery;
}
declare module Twitter.Typeahead {
@@ -82,188 +99,70 @@ declare module Twitter.Typeahead {
*/
interface Dataset {
/**
- * The string used to identify the dataset. Used by typeahead.js
- * to cache intelligently.
+ * The backing data source for suggestions.
+ * Expected to be a function with the signature (query, cb).
+ * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set.
+ * cb can be invoked synchronously or asynchronously.
+ *
*/
- name: string;
- /**
- * The key used to access the value of the datum in the datum object.
- * Defaults to value.
- */
- valueKey?: string;
- /**
- * The max number of suggestions from the dataset to display
- * for a given query. Defaults to 5.
- */
- limit?: number;
- /**
- * The template used to render suggestions. Can be a string or
- * a precompiled template. If not provided, suggestions will render
- * as their value contained in a element (i.e.
value
).
- */
- template?: any;
- /**
- * The template engine used to compile/render template if it is a
- * string. Any engine can use used as long as it adheres to the
- * expected API. Required if template is a string.
- */
- engine?: string;
- /**
- * The header rendered before suggestions in the dropdown menu.
- * Can be either a DOM element or HTML.
- */
- header?: any;
- /**
- * The footer rendered after suggestions in the dropdown menu.
- * Can be either a DOM element or HTML.
- */
- footer?: any;
- /**
- * An array of datums or strings.
- */
- local?: any[];
- /**
- * Can be a URL to a JSON file containing an array of datums or,
- * if more configurability is needed, a prefetch options object.
- */
- prefetch?: any;
- /**
- * Can be a URL to fetch suggestions from when the data provided by
- * local and prefetch is insufficient or, if more configurability is
- * needed, a remote options object.
- */
- remote?: any;
- }
+ source: (query: string, cb: (result: any) => void) => void;
/**
- * Prefetched data is fetched and processed on initialization.
- * If the browser supports localStorage, the processed data will be cached
- * there to prevent additional network requests on subsequent page loads.
- */
- interface PrefetchOptions {
- /**
- * A URL to a JSON file containing an array of datums. Required.
+ * The name of the dataset.
+ * This will be appended to tt-dataset- to form the class name of the containing DOM element.
+ * Must only consist of underscores, dashes, letters (a-z), and numbers.
+ * Defaults to a random number.
*/
- url: string;
+ name?: string;
/**
- * The time (in milliseconds) the prefetched data should be cached
- * in localStorage. Defaults to 86400000 (1 day).
+ * For a given suggestion object, determines the string representation of it.
+ * This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string.
+ * Defaults to value.
*/
- ttl?: number;
+ displayKey?: string;
/**
- * A function that transforms the response body into an array of datums.
- *
- * @param parsedResponse Response body
+ * A hash of templates to be used when rendering the dataset.
+ * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string.
*/
- filter?: (parsedResponse: any) => Datum[];
+ templates?: Templates;
}
- /**
- * Remote data is only used when the data provided by local and prefetch
- * is insufficient. In order to prevent an obscene number of requests
- * being made to remote endpoint, typeahead.js rate-limits remote requests.
- */
- interface RemoteOptions {
- /**
- * A URL to make requests to when the data provided by local and
- * prefetch is insufficient. Required.
- */
- url: string;
+
+ interface Templates {
/**
- * The type of data you're expecting from the server. Defaults to json.
- * @see http://api.jquery.com/jQuery.ajax/ for more info.
+ * Rendered when 0 suggestions are available for the given query.
+ * Can be either a HTML string or a precompiled template.
+ * If it's a precompiled template, the passed in context will contain query
*/
- dataType?: string;
+ empty?: string;
/**
- * Determines whether or not the browser will cache responses.
- * @see http://api.jquery.com/jQuery.ajax/ for more info.
+ * Rendered at the bottom of the dataset.
+ * Can be either a HTML string or a precompiled template.
+ * If it's a precompiled template, the passed in context will contain query and isEmpty.
*/
- cache?: boolean;
+ footer?: string;
/**
- * Sets a timeout for requests.
- * @see http://api.jquery.com/jQuery.ajax/ for more info.
+ * Rendered at the top of the dataset.
+ * Can be either a HTML string or a precompiled template.
+ * If it's a precompiled template, the passed in context will contain query and isEmpty.
*/
- timeout?: number;
+ header?: string;
/**
- * The pattern in url that will be replaced with the user's query
- * when a request is made. Defaults to %QUERY.
+ * Used to render a single suggestion.
+ * If set, this has to be a precompiled template.
+ * The associated suggestion object will serve as the context.
+ * Defaults to the value of displayKey wrapped in a p tag i.e. {{value}}
.
*/
- wildcard?: string;
+ suggestion?: string;
- /**
- * Overrides the request URL. If set, no wildcard substitution will
- * be performed on url.
- *
- * @param url Replacement URL
- * @param uriEncodedQuery Encoded query
- * @returns A valid URL
- */
- replace?: (url: string, uriEncodedQuery: string) => string;
-
- /**
- * The function used for rate-limiting network requests.
- * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'.
- */
- rateLimitFn?: string;
-
- /**
- * The time interval in milliseconds that will be used by rateLimitFn.
- * Defaults to 300.
- */
- rateLimitWait?: number;
-
- /**
- * The max number of parallel requests typeahead.js can have pending.
- * Defaults to 6.
- */
- maxParallelRequests?: number;
-
- /**
- * A pre-request callback. Can be used to set custom headers.
- * @see http://api.jquery.com/jQuery.ajax/ for more info.
- */
- beforeSend?: (jqXhr: JQueryXHR, settings: JQueryAjaxSettings) => void;
-
- /**
- * Transforms the response body into an array of datums.
- *
- * @param parsedResponse Response body
- */
- filter?: (parsedResponse: any) => Datum[];
}
- /**
- * The individual units that compose datasets are called datums.
- * The canonical form of a datum is an object with a value property and
- * a tokens property.
- *
- * For ease of use, datums can also be represented as a string.
- * Strings found in place of datum objects are implicitly converted
- * to a datum object.
- *
- * When datums are rendered as suggestions, the datum object is the
- * context passed to the template engine. This means if you include any
- * arbitrary properties in datum objects, those properties will be
- * available to the template used to render suggestions.
- */
- interface Datum {
- /**
- * The string that represents the underlying value of the datum
- */
- value: string;
-
- /**
- * A collection of single-word strings that aid typeahead.js in
- * matching datums with a given query.
- */
- tokens: string[];
- }
/**
* When initializing a typeahead, there are a number of options you can configure.