diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 270b949aa1..126051faec 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -241,7 +241,7 @@ declare module Backbone { last(): TModel; last(n: number): TModel[]; lastIndexOf(element: TModel, fromIndex?: number): number; - map(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[]; + map(iterator: (element: TModel, index: number, context?: any) => any, context?: any): any[]; max(iterator?: (element: TModel, index: number) => any, context?: any): TModel; min(iterator?: (element: TModel, index: number) => any, context?: any): TModel; reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; diff --git a/colors/colors-tests.ts b/colors/colors-tests.ts index bf83f60056..a7f595fdf1 100644 --- a/colors/colors-tests.ts +++ b/colors/colors-tests.ts @@ -1,5 +1,18 @@ /// +import colors = require("colors"); + var test:string = 'test'; var arr:string[] = ['color', 'odd'.italic.zebra, 'radical'.bold.rainbow, test.underline + 'super'.green]; + +colors.black("abc").trim(); +colors.red("abc").trim(); +colors.green("abc").trim(); +colors.yellow("abc").trim(); +colors.blue("abc").trim(); +colors.magenta("abc").trim(); +colors.cyan("abc").trim(); +colors.white("abc").trim(); +colors.gray("abc").trim(); +colors.grey("abc").trim(); diff --git a/colors/colors.d.ts b/colors/colors.d.ts index e6056b3540..8332ac5bb9 100644 --- a/colors/colors.d.ts +++ b/colors/colors.d.ts @@ -5,6 +5,17 @@ declare module "colors" { export function setTheme(theme:any):any; + + export function black(text: string): string; + export function red(text: string): string; + export function green(text: string): string; + export function yellow(text: string): string; + export function blue(text: string): string; + export function magenta(text: string): string; + export function cyan(text: string): string; + export function white(text: string): string; + export function gray(text: string): string; + export function grey(text: string): string; } interface String { diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 66a6e4d233..2f439a76f0 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1162,7 +1162,7 @@ declare module D3 { /** * If separation is specified, uses the specified function to compute separation between neighboring nodes. If separation is not specified, returns the current separation function */ - seperation: { + separation: { /** * Gets the current separation function */ @@ -1170,7 +1170,7 @@ declare module D3 { /** * Sets the specified function to compute separation between neighboring nodes */ - (seperation: (a: GraphNode, b: GraphNode) => number): TreeLayout; + (separation: (a: GraphNode, b: GraphNode) => number): TreeLayout; }; /** * Gets or sets the available layout size @@ -1382,9 +1382,9 @@ declare module D3 { } nodes(root: GraphNode): GraphNode[]; links(nodes: GraphNode[]): GraphLink[]; - seperation: { + separation: { (): (a: GraphNode, b: GraphNode) => number; - (seperation: (a: GraphNode, b: GraphNode) => number): ClusterLayout; + (separation: (a: GraphNode, b: GraphNode) => number): ClusterLayout; } size: { (): number[]; diff --git a/easeljs/easeljs-tests.ts b/easeljs/easeljs-tests.ts index 552f82e7ae..b036ae5702 100644 --- a/easeljs/easeljs-tests.ts +++ b/easeljs/easeljs-tests.ts @@ -71,4 +71,18 @@ function test_canvas_tick() { var canvas = document.getElementById('canvas'); var stage = new createjs.Stage(canvas); var stage = createjs.Ticker.addEventListener("tick", stage); +} + +function matrixDecompose() { + var matrix = new createjs.Matrix2D(); + var shape = new createjs.Shape(); + var transform = matrix.decompose(shape); + var transformData = matrix.decompose(); + shape.x = transformData.x; + shape.y = transformData.y; + shape.scaleX = transformData.scaleX; + shape.scaleY = transformData.scaleY; + shape.skewX = transformData.skewX; + shape.skewY = transformData.skewY; + shape.rotation = transformData.rotation; } \ No newline at end of file diff --git a/easeljs/easeljs.d.ts b/easeljs/easeljs.d.ts index bd6a31de0f..08378828a2 100644 --- a/easeljs/easeljs.d.ts +++ b/easeljs/easeljs.d.ts @@ -383,6 +383,7 @@ declare module createjs { appendTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number): Matrix2D; clone(): Matrix2D; copy(matrix: Matrix2D): Matrix2D; + decompose(): {x: number; y: number; scaleX: number; scaleY: number; rotation: number; skewX: number; skewY: number}; decompose(target: Object): Matrix2D; identity(): Matrix2D; initialize(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number): Matrix2D; diff --git a/express/express.d.ts b/express/express.d.ts index cf5014e82b..d7d3f0d896 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -681,6 +681,9 @@ declare module "express" { header(field: any): Response; header(field: string, value?: string): Response; + // Property indicating if HTTP headers has been sent for the response. + headersSent: boolean; + /** * Get value for header `field`. * diff --git a/hammerjs/hammerjs-1.1.3-tests.ts b/hammerjs/hammerjs-1.1.3-tests.ts new file mode 100644 index 0000000000..42c5ccea32 --- /dev/null +++ b/hammerjs/hammerjs-1.1.3-tests.ts @@ -0,0 +1,49 @@ +/// +/// + +// plugin check +if (!Hammer.HAS_TOUCHEVENTS && !Hammer.HAS_POINTEREVENTS) { + Hammer.plugins.fakeMultitouch(); + Hammer.plugins.showTouches(); +} + +// instance method check +var el = document.getElementById("container"); + +Hammer(el).on("doubletap", function () { + alert('you doubletapped me!'); +}); + +var hammertime = Hammer(el, { + drag: false, + transform: false +}).off("tap", function (event:HammerEvent) { + alert('hello!'); +}); + +hammertime.enable(false); + +hammertime.on("touch drag transform", function (ev: HammerEvent) { + if (!ev.gesture) { + return; + } + + if (ev.gesture.deltaX >= 20) { + hammertime.trigger("swipe", ev.gesture); + } +}); + +// jQuery check +$("#element") + .hammer({ + // Options + }) + .on("tap", function (ev) { + console.log(ev); + }); + +$("#container").hammer({ + prevent_default: false, + drag_block_vertical: false +}).on("hold tap doubletap transformstart transform transformend dragstart drag dragend release swipe", function (ev) { +}); \ No newline at end of file diff --git a/hammerjs/hammerjs-1.1.3.d.ts b/hammerjs/hammerjs-1.1.3.d.ts new file mode 100644 index 0000000000..4e7f69306c --- /dev/null +++ b/hammerjs/hammerjs-1.1.3.d.ts @@ -0,0 +1,142 @@ +// Type definitions for Hammer.js 1.1.3 +// Project: http://eightmedia.github.com/hammer.js/ +// Definitions by: Boris Yankov , Drew Noakes +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var Hammer: HammerStatic; + +interface HammerStatic { + (element: any, options?: HammerOptions): HammerInstance; + + VERSION: number; + HAS_POINTEREVENTS: boolean; + HAS_TOUCHEVENTS: boolean; + UPDATE_VELOCITY_INTERVAL: number; + POINTER_MOUSE: HammerPointerType; + POINTER_TOUCH: HammerPointerType; + POINTER_PEN: HammerPointerType; + + DIRECTION_UP: HammerDirectionType; + DIRECTION_DOWN: HammerDirectionType; + DIRECTION_LEFT: HammerDirectionType; + DIRECTION_RIGH: HammerDirectionType; + + EVENT_START: HammerTouchEventState; + EVENT_MOVE: HammerTouchEventState; + EVENT_END: HammerTouchEventState; + + plugins: any; + gestures: any; + READY: boolean; +} + +declare class HammerInstance { + constructor(element: any, options?: HammerOptions); + + on(gesture: string, handler: (event: HammerEvent) => void): HammerInstance; + off(gesture: string, handler: (event: HammerEvent) => void): HammerInstance; + enable(toggle: boolean): HammerInstance; + + // You shouldn't normally use this internal method. Only use it when you know what you're doing! You can read the sourcecode for information about how to use this. + trigger(gesture: string, eventData: HammerGestureEventData): HammerInstance; +} + +// Gesture Options : https://github.com/EightMedia/hammer.js/wiki/Getting-Started#gesture-options +interface HammerOptions { + behavior?: { + contentZooming?: string; + tapHighlightColor?: string; + touchAction?: string; + touchCallout?: string; + userDrag?: string; + userSelect?: string; + }; + doubleTapDistance?: number; + doubleTapInterval?: number; + drag?: boolean; + dragBlockHorizontal?: boolean; + dragBlockVertical?: boolean; + dragDistanceCorrection?: boolean; + dragLockMinDistance?: number; + dragLockToAxis?: boolean; + dragMaxTouches?: number; + dragMinDistance?: number; + gesture?: boolean; + hold?: boolean; + holdThreshold?: number; + holdTimeout?: number; + preventDefault?: boolean; + preventMouse?: boolean; + release?: boolean; + showTouches?: boolean; + swipe?: boolean; + swipeMaxTouches?: number; + swipeMinTouches?: number; + swipeVelocityX?: number; + swipeVelocityY?: number; + tap?: boolean; + tapAlways?: boolean; + tapMaxDistance?: number; + tapMaxTime?: number; + touch?: boolean; + transform?: boolean; + transformMinRotation?: number; + transformMinScale?: number; +} + +interface HammerGestureEventData { + timestamp: number; + target: HTMLElement; + touches: HammerPoint[]; + pointerType: HammerPointerType; + center: HammerPoint; + deltaTime: number; + deltaX: number; + deltaY: number; + velocityX: number; + velocityY: number; + angle: number; + interimAngle: number; + direction: HammerDirectionType; + interimDirection: HammerDirectionType; + distance: number; + scale: number; + rotation: number; + eventType: HammerTouchEventState; + srcEvent: any; + startEvent: any; + + stopPropagation(): void; + preventDefault(): void; + stopDetect(): void; +} + +interface HammerPoint { + clientX: number; + clientY: number; + pageX: number; + pageY: number; +} + +interface HammerEvent { + type: string; + gesture: HammerGestureEventData; + + stopPropagation(): void; + preventDefault(): void; + +} + +declare enum HammerPointerType { +} +declare enum HammerDirectionType { +} +declare enum HammerTouchEventState { +} + +interface JQuery { + hammer(options?: HammerOptions): JQuery; +} diff --git a/hammerjs/hammerjs-tests.ts b/hammerjs/hammerjs-tests.ts index 23fa92d4d2..a17c16287c 100644 --- a/hammerjs/hammerjs-tests.ts +++ b/hammerjs/hammerjs-tests.ts @@ -1,49 +1,115 @@ -/// -/// - -// plugin check -if (!Hammer.HAS_TOUCHEVENTS && !Hammer.HAS_POINTEREVENTS) { - Hammer.plugins.fakeMultitouch(); - Hammer.plugins.showTouches(); -} - -// instance method check -var el = document.getElementById("container"); - -Hammer(el).on("doubletap", function () { - alert('you doubletapped me!'); -}); - -var hammertime = Hammer(el, { - drag: false, - transform: false -}).off("tap", function (event:HammerEvent) { - alert('hello!'); -}); - -hammertime.enable(false); - -hammertime.on("touch drag transform", function (ev: HammerEvent) { - if (!ev.gesture) { - return; - } - - if (ev.gesture.deltaX >= 20) { - hammertime.trigger("swipe", ev.gesture); - } -}); - -// jQuery check -$("#element") - .hammer({ - // Options - }) - .on("tap", function (ev) { - console.log(ev); - }); - -$("#container").hammer({ - prevent_default: false, - drag_block_vertical: false -}).on("hold tap doubletap transformstart transform transformend dragstart drag dragend release swipe", function (ev) { -}); \ No newline at end of file +// Tests based on examples at http://hammerjs.github.io/examples/ + +/// + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer( myElement ); + + // listen to events... + mc.on( "panleft panright tap press", function ( ev ) + { + myElement.textContent = ev.type + " gesture detected."; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer( myElement ); + + // let the pan gesture support all directions. + // this will block the vertical scrolling on a touch-device while on the element + mc.get( 'pan' ).set( {direction: Hammer.DIRECTION_ALL} ); + + // listen to events... + mc.on( "panleft panright panup pandown tap press", function ( ev:HammerInput ) + { + myElement.textContent = ev.type + " gesture detected."; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + var mc = new Hammer.Manager( myElement ); + + // create a pinch and rotate recognizer + // these require 2 pointers + var pinch = new Hammer.Pinch(); + var rotate = new Hammer.Rotate(); + + // we want to detect both the same time + pinch.recognizeWith( rotate ); + + // add to the Manager + mc.add( [pinch, rotate] ); + + + mc.on( "pinch rotate", function ( ev:HammerInput ) + { + myElement.textContent += ev.type + " "; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. + var mc = new Hammer.Manager( myElement ); + + // Default, tap recognizer + mc.add( new Hammer.Tap() ); + + // Tap recognizer with minimal 4 taps + mc.add( new Hammer.Tap( {event: 'quadrupletap', taps: 4} ) ); + + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + // the tap event will be emitted on every tap + mc.get( 'quadrupletap' ).recognizeWith( 'tap' ); + + + mc.on( "tap quadrupletap", function ( ev ) + { + myElement.textContent += ev.type + " "; + } ); +})(); + + +(() => +{ + var myElement = document.getElementById( 'myElement' ); + + // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. + var mc = new Hammer.Manager( myElement ); + + + // Tap recognizer with minimal 2 taps + mc.add( new Hammer.Tap( {event: 'doubletap', taps: 2} ) ); + // Single tap recognizer + mc.add( new Hammer.Tap( {event: 'singletap'} ) ); + + + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + mc.get( 'doubletap' ).recognizeWith( 'singletap' ); + // we only want to trigger a tap, when we don't have detected a doubletap + mc.get( 'singletap' ).requireFailure( 'doubletap' ); + + + mc.on( "singletap doubletap", function ( ev ) + { + myElement.textContent += ev.type + " "; + } ); +})(); \ No newline at end of file diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 6f4c0d4cef..a3a7aed42e 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -1,142 +1,327 @@ -// Type definitions for Hammer.js 1.1.3 -// Project: http://eightmedia.github.com/hammer.js/ -// Definitions by: Boris Yankov , Drew Noakes -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -/// - -declare var Hammer: HammerStatic; - -interface HammerStatic { - (element: any, options?: HammerOptions): HammerInstance; - - VERSION: number; - HAS_POINTEREVENTS: boolean; - HAS_TOUCHEVENTS: boolean; - UPDATE_VELOCITY_INTERVAL: number; - POINTER_MOUSE: HammerPointerType; - POINTER_TOUCH: HammerPointerType; - POINTER_PEN: HammerPointerType; - - DIRECTION_UP: HammerDirectionType; - DIRECTION_DOWN: HammerDirectionType; - DIRECTION_LEFT: HammerDirectionType; - DIRECTION_RIGH: HammerDirectionType; - - EVENT_START: HammerTouchEventState; - EVENT_MOVE: HammerTouchEventState; - EVENT_END: HammerTouchEventState; - - plugins: any; - gestures: any; - READY: boolean; -} - -declare class HammerInstance { - constructor(element: any, options?: HammerOptions); - - on(gesture: string, handler: (event: HammerEvent) => void): HammerInstance; - off(gesture: string, handler: (event: HammerEvent) => void): HammerInstance; - enable(toggle: boolean): HammerInstance; - - // You shouldn't normally use this internal method. Only use it when you know what you're doing! You can read the sourcecode for information about how to use this. - trigger(gesture: string, eventData: HammerGestureEventData): HammerInstance; -} - -// Gesture Options : https://github.com/EightMedia/hammer.js/wiki/Getting-Started#gesture-options -interface HammerOptions { - behavior?: { - contentZooming?: string; - tapHighlightColor?: string; - touchAction?: string; - touchCallout?: string; - userDrag?: string; - userSelect?: string; - }; - doubleTapDistance?: number; - doubleTapInterval?: number; - drag?: boolean; - dragBlockHorizontal?: boolean; - dragBlockVertical?: boolean; - dragDistanceCorrection?: boolean; - dragLockMinDistance?: number; - dragLockToAxis?: boolean; - dragMaxTouches?: number; - dragMinDistance?: number; - gesture?: boolean; - hold?: boolean; - holdThreshold?: number; - holdTimeout?: number; - preventDefault?: boolean; - preventMouse?: boolean; - release?: boolean; - showTouches?: boolean; - swipe?: boolean; - swipeMaxTouches?: number; - swipeMinTouches?: number; - swipeVelocityX?: number; - swipeVelocityY?: number; - tap?: boolean; - tapAlways?: boolean; - tapMaxDistance?: number; - tapMaxTime?: number; - touch?: boolean; - transform?: boolean; - transformMinRotation?: number; - transformMinScale?: number; -} - -interface HammerGestureEventData { - timestamp: number; - target: HTMLElement; - touches: HammerPoint[]; - pointerType: HammerPointerType; - center: HammerPoint; - deltaTime: number; - deltaX: number; - deltaY: number; - velocityX: number; - velocityY: number; - angle: number; - interimAngle: number; - direction: HammerDirectionType; - interimDirection: HammerDirectionType; - distance: number; - scale: number; - rotation: number; - eventType: HammerTouchEventState; - srcEvent: any; - startEvent: any; - - stopPropagation(): void; - preventDefault(): void; - stopDetect(): void; -} - -interface HammerPoint { - clientX: number; - clientY: number; - pageX: number; - pageY: number; -} - -interface HammerEvent { - type: string; - gesture: HammerGestureEventData; - - stopPropagation(): void; - preventDefault(): void; - -} - -declare enum HammerPointerType { -} -declare enum HammerDirectionType { -} -declare enum HammerTouchEventState { -} - -interface JQuery { - hammer(options?: HammerOptions): JQuery; -} +// Type definitions for Hammer.js 2.0.4 +// Project: http://hammerjs.github.io/ +// Definitions by: Philip Bulley +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Hammer:HammerStatic; + +interface HammerStatic +{ + new( element:HTMLElement, options?:any ): HammerManager; + + defaults:HammerDefaults; + + VERSION: number; + + INPUT_START: number; + INPUT_MOVE: number; + INPUT_END: number; + INPUT_CANCEL: number; + + STATE_POSSIBLE: number; + STATE_BEGAN: number; + STATE_CHANGED: number; + STATE_ENDED: number; + STATE_RECOGNIZED: number; + STATE_CANCELLED: number; + STATE_FAILED: number; + + DIRECTION_NONE: number; + DIRECTION_LEFT: number; + DIRECTION_RIGHT: number; + DIRECTION_UP: number; + DIRECTION_DOWN: number; + DIRECTION_HORIZONTAL: number; + DIRECTION_VERTICAL: number; + DIRECTION_ALL: number; + + Manager: HammerManager; + Input: HammerInput; + TouchAction: TouchAction; + + TouchInput: TouchInput; + MouseInput: MouseInput; + PointerEventInput: PointerEventInput; + TouchMouseInput: TouchMouseInput; + SingleTouchInput: SingleTouchInput; + + Recognizer: RecognizerStatic; + AttrRecognizer: AttrRecognizerStatic; + Tap: TapRecognizerStatic; + Pan: PanRecognizerStatic; + Swipe: SwipeRecognizerStatic; + Pinch: PinchRecognizerStatic; + Rotate: RotateRecognizerStatic; + Press: PressRecognizerStatic; + + on( target:EventTarget, types:string, handler:Function ):void; + off( target:EventTarget, types:string, handler:Function ):void; + each( obj:any, iterator:Function, context:any ): void; + merge( dest:any, src:any ): any; + extend( dest:any, src:any, merge:boolean ): any; + inherit( child:Function, base:Function, properties:any ):any; + bindFn( fn:Function, context:any ):Function; + prefixed( obj:any, property:string ):string; +} + +interface HammerDefaults +{ + domEvents:boolean; + enable:boolean; + preset:any[]; + touchAction:string; + cssProps:CssProps; + + inputClass():void; + inputTarget():void; +} + +interface CssProps +{ + contentZooming:string; + tapHighlightColor:string; + touchCallout:string; + touchSelect:string; + userDrag:string; + userSelect:string; +} + +interface HammerOptions extends HammerDefaults +{ + +} + +interface HammerManager +{ + new( element:HTMLElement, options?:any ):HammerManager; + + add( recogniser:Recognizer ):Recognizer; + add( recogniser:Recognizer ):HammerManager; + add( recogniser:Recognizer[] ):Recognizer; + add( recogniser:Recognizer[] ):HammerManager; + destroy():void; + emit( event:string, data:any ):void; + get( recogniser:Recognizer ):Recognizer; + get( recogniser:string ):Recognizer; + off( events:string, handler:( event:HammerInput ) => void ):void; + on( events:string, handler:( event:HammerInput ) => void ):void; + recognize( inputData:any ):void; + remove( recogniser:Recognizer ):HammerManager; + remove( recogniser:string ):HammerManager; + set( options:HammerOptions ):HammerManager; + stop( force:boolean ):void; +} + +declare class HammerInput +{ + constructor( manager:HammerManager, callback:Function ); + + destroy():void; + handler():void; + init():void; + + /** Name of the event. Like panstart. */ + type:string; + + /** Movement of the X axis. */ + deltaX:number; + + /** Movement of the Y axis. */ + deltaY:number; + + /** Total time in ms since the first input. */ + deltaTime:number; + + /** Distance moved. */ + distance:number; + + /** Angle moved. */ + angle:number; + + /** Velocity on the X axis, in px/ms. */ + velocityX:number; + + /** Velocity on the Y axis, in px/ms */ + velocityY:number; + + /** Highest velocityX/Y value. */ + velocity:number; + + /** Direction moved. Matches the DIRECTION constants. */ + direction:number; + + /** Direction moved from it's starting point. Matches the DIRECTION constants. */ + offsetDirection:string; + + /** Scaling that has been done when multi-touch. 1 on a single touch. */ + scale:number; + + /** Rotation that has been done when multi-touch. 0 on a single touch. */ + rotation:number; + + /** Center position for multi-touch, or just the single pointer. */ + center:HammerPoint; + + /** Source event object, type TouchEvent, MouseEvent or PointerEvent. */ + srcEvent:Event; // TODO: Update to Union Type (TouchEvent | MouseEvent | PointerEvent) if it lands in TS1.4 + + /** Target that received the event. */ + target:HTMLElement; + + /** Primary pointer type, could be touch, mouse, pen or kinect. */ + pointerType:string; + + /** Event type, matches the INPUT constants. */ + eventType:string; + + /** true when the first input. */ + isFirst:boolean; + + /** true when the final (last) input. */ + isFinal:boolean; + + /** Array with all pointers, including the ended pointers (touchend, mouseup). */ + pointers:any[]; + + /** Array with all new/moved/lost pointers. */ + changedPointers:any[]; + + /** Reference to the srcEvent.preventDefault() method. Only for experts! */ + preventDefault:Function; +} + +declare class MouseInput extends HammerInput +{ + constructor( manager:HammerManager, callback:Function ); +} + +declare class PointerEventInput extends HammerInput +{ + constructor( manager:HammerManager, callback:Function ); +} + +declare class SingleTouchInput extends HammerInput +{ + constructor( manager:HammerManager, callback:Function ); +} + +declare class TouchInput extends HammerInput +{ + constructor( manager:HammerManager, callback:Function ); +} + +declare class TouchMouseInput extends HammerInput +{ + constructor( manager:HammerManager, callback:Function ); +} + +interface RecognizerStatic +{ + new( options?:any ):Recognizer; +} + +interface Recognizer +{ + defaults:any; + + canEmit():boolean; + canRecognizeWith( otherRecognizer:Recognizer ):boolean; + dropRecognizeWith( otherRecognizer:Recognizer ):Recognizer; + dropRecognizeWith( otherRecognizer:string ):Recognizer; + dropRequireFailure( otherRecognizer:Recognizer ):Recognizer; + dropRequireFailure( otherRecognizer:string ):Recognizer; + emit( input:HammerInput ):void; + getTouchAction():any[]; + hasRequireFailures():boolean; + process( inputData:HammerInput ):string; + recognize( inputData:HammerInput ):void; + recognizeWith( otherRecognizer:Recognizer ):Recognizer; + recognizeWith( otherRecognizer:string ):Recognizer; + requireFailure( otherRecognizer:Recognizer ):Recognizer; + requireFailure( otherRecognizer:string ):Recognizer; + reset():void; + set( options?:any ):Recognizer; + tryEmit( input:HammerInput ):void; +} + +interface AttrRecognizerStatic +{ + attrTest( input:HammerInput ):boolean; + process( input:HammerInput ):any; +} + +interface AttrRecognizer extends Recognizer +{ + new( options?:any ):AttrRecognizer; +} + +interface PanRecognizerStatic +{ + new( options?:any ):PanRecognizer; +} + +interface PanRecognizer extends AttrRecognizer +{ +} + +interface PinchRecognizerStatic +{ + new( options?:any ):PinchRecognizer; +} + +interface PinchRecognizer extends AttrRecognizer +{ +} + +interface PressRecognizerStatic +{ + new( options?:any ):PressRecognizer; +} + +interface PressRecognizer extends AttrRecognizer +{ +} + +interface RotateRecognizerStatic +{ + new( options?:any ):RotateRecognizer; +} + +interface RotateRecognizer extends AttrRecognizer +{ +} + +interface SwipeRecognizerStatic +{ + new( options?:any ):SwipeRecognizer; +} + +interface SwipeRecognizer +{ +} + +interface TapRecognizerStatic +{ + new( options?:any ):TapRecognizer; +} + +interface TapRecognizer extends AttrRecognizer +{ +} + +declare class TouchAction +{ + constructor( manager:HammerManager, value:string ); + + compute():string; + preventDefaults( input:HammerInput ):void; + preventSrc( srcEvent:any ):void; + set( value:string ):void; + update():void; +} + +interface HammerPoint +{ + x: number; + y: number; +} diff --git a/linq/linq.d.ts b/linq/linq.d.ts index 461fe2eb06..c15bc895e4 100644 --- a/linq/linq.d.ts +++ b/linq/linq.d.ts @@ -208,7 +208,7 @@ declare module linq { ThenBy(keySelector: ($) => T): OrderedEnumerable; ThenBy(keySelector: string): OrderedEnumerable; ThenByDescending(keySelector: ($) => T): OrderedEnumerable; - ThenByDescending(keySelector: T): OrderedEnumerable; + ThenByDescending(keySelector: string): OrderedEnumerable; } interface Grouping extends Enumerable { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index dfa5e2e6a0..364ec3de84 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6324,6 +6324,14 @@ declare module _ { noop(): void; } + //_.constant + interface LoDashStatic { + /** + * Creates a function that returns value.. + **/ + constant(value: T): T; + } + //_.create interface LoDashStatic { /** diff --git a/nock/nock.d.ts b/nock/nock.d.ts index 40b728d491..18119e1db0 100644 --- a/nock/nock.d.ts +++ b/nock/nock.d.ts @@ -12,6 +12,12 @@ declare module "nock" { module nock { export function cleanAll(): void; + + export function disableNetConnect(): void; + export function enableNetConnect(): void; + export function enableNetConnect(regex: RegExp): void; + export function enableNetConnect(domain: string): void; + export var recorder: Recorder; export interface Scope { diff --git a/node-imap/imap-tests.ts b/node-imap/imap-tests.ts new file mode 100644 index 0000000000..61f4b2e0c1 --- /dev/null +++ b/node-imap/imap-tests.ts @@ -0,0 +1,126 @@ +import Imap = require('imap'); +var inspect = require('util').inspect; + +var imap = new Imap({ + user: 'mygmailname@gmail.com', + password: 'mygmailpassword', + host: 'imap.gmail.com', + port: 993, + tls: true +}); + +imap.once('ready', function () { + imap.openBox('INBOX', true,function (err, box) { + if (err) throw err; + var f = imap.seq.fetch('1:3', { + bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)', + struct: true + }); + f.on('message', function (msg, seqno) { + console.log('Message #%d', seqno); + var prefix = '(#' + seqno + ') '; + msg.on('body', function (stream, info) { + var buffer = ''; + stream.on('data', function (chunk) { + buffer += chunk.toString('utf8'); + }); + stream.once('end', function () { + console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer))); + }); + }); + msg.once('attributes', function (attrs) { + console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8)); + }); + msg.once('end', function () { + console.log(prefix + 'Finished'); + }); + }); + f.once('error', function (err) { + console.log('Fetch error: ' + err); + }); + f.once('end', function () { + console.log('Done fetching all messages!'); + imap.end(); + }); + }); +}); + +imap.once('error', function (err) { + console.log(err); +}); + +imap.once('end', function () { + console.log('Connection ended'); +}); + +imap.connect(); + +imap.openBox('INBOX', true, function (err, box) { + if (err) throw err; + var f = imap.seq.fetch(box.messages.total + ':*', { bodies: ['HEADER.FIELDS (FROM)', 'TEXT'] }); + f.on('message', function (msg, seqno) { + console.log('Message #%d', seqno); + var prefix = '(#' + seqno + ') '; + msg.on('body', function (stream, info) { + if (info.which === 'TEXT') + console.log(prefix + 'Body [%s] found, %d total bytes', inspect(info.which), info.size); + var buffer = '', count = 0; + stream.on('data', function (chunk) { + count += chunk.length; + buffer += chunk.toString('utf8'); + if (info.which === 'TEXT') + console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), count, info.size); + }); + stream.once('end', function () { + if (info.which !== 'TEXT') + console.log(prefix + 'Parsed header: %s', inspect(Imap.parseHeader(buffer))); + else + console.log(prefix + 'Body [%s] Finished', inspect(info.which)); + }); + }); + msg.once('attributes', function (attrs) { + console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8)); + }); + msg.once('end', function () { + console.log(prefix + 'Finished'); + }); + }); + f.once('error', function (err) { + console.log('Fetch error: ' + err); + }); + f.once('end', function () { + console.log('Done fetching all messages!'); + imap.end(); + }); +}); + +var fs = require('fs'), fileStream : any; + +imap.openBox('INBOX', true,function (err, box) { + if (err) throw err; + imap.search(['UNSEEN', ['SINCE', 'May 20, 2010']], function (err : Error, results: any) { + if (err) throw err; + var f = imap.fetch(results, { bodies: '' }); + f.on('message', function (msg, seqno) { + console.log('Message #%d', seqno); + var prefix = '(#' + seqno + ') '; + msg.on('body', function (stream, info) { + console.log(prefix + 'Body'); + stream.pipe(fs.createWriteStream('msg-' + seqno + '-body.txt')); + }); + msg.once('attributes', function (attrs) { + console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8)); + }); + msg.once('end', function () { + console.log(prefix + 'Finished'); + }); + }); + f.once('error', function (err) { + console.log('Fetch error: ' + err); + }); + f.once('end', function () { + console.log('Done fetching all messages!'); + imap.end(); + }); + }); +}); diff --git a/node-imap/imap.d.ts b/node-imap/imap.d.ts new file mode 100644 index 0000000000..2b387136fe --- /dev/null +++ b/node-imap/imap.d.ts @@ -0,0 +1,102 @@ +// Type definitions for node imap +// Project: https://github.com/mscdex/node-imap +// Definitions by: Steve Fenton +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "imap" { + interface ImapOptions { + user: string; + password: string; + host: string; + port: number; + tls: boolean; + } + + interface ImapBox { + name: string; + readOnly: boolean; + newKeywords: boolean; + uidvalidity: number; + uidnext: number; + flags: any[]; // TODO + permFlags: any[]; // TODO + persistentUIDs: boolean; + messages: { + total: number; + 'new': number; + unseen: number; + } + } + + interface ImapChunk { + toString(charset: string): string; + length: number; + } + + interface ImapFetch { + once(event: 'end', callback: () => void): void; + once(event: 'error', callback: (error: Error) => void): void; + once(event: string, callback: Function): void; + + on(event: 'message', callback: (msg: ImapMessage, seqno: number) => void): void; + on(event: string, callback: Function): void; + } + + interface ImapBodyStream { + once(event: 'end', callback: () => void): void; + once(event: string, callback: Function): void; + + on(event: 'data', callback: (chunk: ImapChunk) => void): void; + on(event: string, callback: Function): void; + + pipe(stream: any): void; + } + + interface ImapMessage { + // TODO: typeof attributes + once(event: 'attributes', callback: (attributes: any) => void): void; + once(event: string, callback: Function): void; + + // TODO: typeof info + on(event: 'body', callback: (stream: ImapBodyStream, info: any) => void): void; + on(event: string, callback: Function): void; + } + + class Imap { + constructor(options: ImapOptions); + + connect(): void; + + //TODO: + // param a + openBox(name: string, a: boolean, callback: (err: Error, box: ImapBox) => void) : void; + + //TODO: + // param a + // param b + once(event: 'end', callback: () => void): void; + once(event: 'error', callback: (error: Error) => void): void; + once(a: string, callback: Function) : void; + + end(): void; + + //TODO: + // return type + parseHeader(header: string): any; + static parseHeader(header: string): any; + + search(searchTerms: any[], callback: Function): void; + + fetch(results: any, options: {}): ImapFetch; + + //TODO: + // type + seq: { + fetch(messageSourceQuery: string, options: {}): ImapFetch; + }; + } + + export = Imap; +} diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index 2da9c47c62..a564ac85fa 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -465,7 +465,7 @@ declare module "zlib" { } declare module "os" { - export function tmpDir(): string; + export function tmpdir(): string; export function hostname(): string; export function type(): string; export function platform(): string; @@ -767,13 +767,13 @@ declare module "dgram" { port: number; size: number; } - + interface AddressInfo { - address: string; - family: string; - port: number; + address: string; + family: string; + port: number; } - + export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; interface Socket extends events.EventEmitter { diff --git a/node/node.d.ts b/node/node.d.ts index f2b5eee24c..99ab5eccd0 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -465,7 +465,7 @@ declare module "zlib" { } declare module "os" { - export function tmpDir(): string; + export function tmpdir(): string; export function hostname(): string; export function type(): string; export function platform(): string; @@ -528,8 +528,8 @@ declare module "https" { }; export interface Server extends tls.Server { } export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; + export function request(options: RequestOptions, callback?: (res: http.ClientResponse) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: http.ClientResponse) =>void ): http.ClientRequest; export var globalAgent: Agent; } diff --git a/pouchDB/pouch.d.ts b/pouchDB/pouch.d.ts index 47ffcad606..40a28cf23d 100644 --- a/pouchDB/pouch.d.ts +++ b/pouchDB/pouch.d.ts @@ -217,6 +217,12 @@ interface PouchDB extends PouchApi { } declare var PouchDB: PouchDB; + +// Support AMD require +declare module 'pouchdb' { + export = PouchDB; +} + // // emit is the function that the PouchFilter.map function should call in order to add a particular item to // a filter view. diff --git a/q/Q-tests.ts b/q/Q-tests.ts index 48a3224bc1..9dc49d9792 100644 --- a/q/Q-tests.ts +++ b/q/Q-tests.ts @@ -94,6 +94,7 @@ Q.fbind((dateString?: string) => new Date(dateString), "11/11/1991")().then(d => Q.when(8, num => num + "!"); Q.when(Q(8), num => num + "!").then(str => str.split(',')); +var voidPromise: Q.Promise = Q.when(); declare function saveToDisk(): Q.Promise; declare function saveToCloud(): Q.Promise; diff --git a/q/Q.d.ts b/q/Q.d.ts index 59e891c527..3afd90406c 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -3,18 +3,11 @@ // Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - /** * If value is a Q promise, returns the promise. * If value is a promise from another library it is coerced into a Q promise (where possible). */ declare function Q(promise: Q.IPromise): Q.Promise; -/** - * If value is a Q promise, returns the promise. - * If value is a promise from another library it is coerced into a Q promise (where possible). - */ -declare function Q(promise: JQueryPromise): Q.Promise; /** * If value is not a promise, returns a promise that is fulfilled with value. */ @@ -188,6 +181,9 @@ declare module Q { reason?: any; } + // If no value provided, returned promise will be of void type + export function when(): Promise; + // if no fulfill, reject, or progress provided, returned promise will be of same type export function when(value: IPromise): Promise; export function when(value: T): Promise; diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 417ea1e2ff..9ea16186d3 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -7241,7 +7241,7 @@ declare module SP { } export class Status { - static addStatus(strTitle: string, strHtml: string, atBegining: boolean): string; + static addStatus(strTitle: string, strHtml?: string, atBegining?: boolean): string; static appendStatus(sid: string, strTitle: string, strHtml: string): string; static updateStatus(sid: string, strHtml: string): void; static setStatusPriColor(sid: string, strColor: string): void; @@ -8410,11 +8410,11 @@ declare module SP.WorkflowServices { /** RestrictToScope is a GUID value, used in conjunction with the RestrictToType property to further restrict the scope of the definition. For example, if the RestrictToType is "List", then setting the RestrictToScope to a particular list identifier limits the definition to be associable only to the specified list. If the RestrictToType is "List" but the RestrictToScope is null or the empty string, then the definition is associable to any list. */ - get_restrictScope(): string; + get_restrictToScope(): string; /** RestrictToScope is a GUID value, used in conjunction with the RestrictToType property to further restrict the scope of the definition. For example, if the RestrictToType is "List", then setting the RestrictToScope to a particular list identifier limits the definition to be associable only to the specified list. If the RestrictToType is "List" but the RestrictToScope is null or the empty string, then the definition is associable to any list. */ - set_restrictScope(value: string): string; + set_restrictToScope(value: string): string; /** RestrictToType determines the possible event source type for a workflow subscription that uses this definition. Possible values include "List", "Site", the empty string, or null. */ get_restrictToType(): string; diff --git a/snapsvg/snapsvg-tests.ts b/snapsvg/snapsvg-tests.ts new file mode 100644 index 0000000000..b07bc20079 --- /dev/null +++ b/snapsvg/snapsvg-tests.ts @@ -0,0 +1,83 @@ +//Copied from the snap homepage http://snapsvg.io/ + +/// +// First lets create our drawing surface out of existing SVG element +// If you want to create new surface just provide dimensions +// like s = Snap(800, 600); +var s = Snap("#svg"); +// Lets create big circle in the middle: +var bigCircle = s.circle(150, 150, 100); +// By default its black, lets change its attributes +bigCircle.attr({ + fill: "#bada55", + stroke: "#000", + strokeWidth: 5 +}); +// Now lets create another small circle: +var smallCircle = s.circle(100, 150, 70); +// Lets put this small circle and another one into a group: +var discs = s.group(smallCircle, s.circle(200, 150, 70)); +// Now we can change attributes for the whole group +discs.attr({ + fill: "#fff" +}); +// Now more interesting stuff +// Lets assign this group as a mask for our big circle +bigCircle.attr({ + mask: discs +}); +// Despite our small circle now is a part of a group +// and a part of a mask we could still access it: +smallCircle.animate({ r: 50 }, 1000); +// We don’t have reference for second small circle, +// but we could easily grab it with CSS selectors: +discs.select("circle:nth-child(2)").animate({ r: 50 }, 1000); +// Now lets create pattern +var p = s.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({ + fill: "none", + stroke: "#bada55", + strokeWidth: 5 +}); +// To create pattern, +// just specify dimensions in pattern method: +p = p.pattern(0, 0, 10, 10); +// Then use it as a fill on big circle +bigCircle.attr({ + fill: p +}); +// We could also grab pattern from SVG +// already embedded into our page +discs.attr({ + fill: Snap("#pattern") +}); +// Lets change fill of circles to gradient +// This string means relative radial gradient +// from white to black +discs.attr({ fill: "r()#fff-#000" }); +// Note that you have two gradients for each circle +// If we want them to share one gradient, +// we need to use absolute gradient with capital R +discs.attr({ fill: "R(150, 150, 100)#fff-#000" }); +// Of course we could animate color as well +p.select("path").animate({ stroke: "#f00" }, 1000); +// Now lets load external SVG file: +Snap.load("mascot.svg", function (f:Snap.Fragment) { + // Note that we traversre and change attr before SVG + // is even added to the page + f.selectAll("polygon[fill='#09B39C']").attr({ fill: "#bada55" }); + var g = f.select("g"); + s.append(g); + // Making croc draggable. Go ahead drag it around! + g.drag(); + // Obviously drag could take event handlers too + // That’s better! selectAll for the rescue. +}); +// Writing text as simple as: +s.text(200, 100, "Snap.svg"); +// Provide an array of strings (or arrays), to generate tspans +var t = s.text(200, 120, ["Snap", ".", "svg"]); +t.selectAll("tspan:nth-child(3)").attr({ + fill: "#900", + "font-size": "20px" +}); + diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts new file mode 100644 index 0000000000..821f27de0d --- /dev/null +++ b/snapsvg/snapsvg.d.ts @@ -0,0 +1,289 @@ +// Type definitions for Snap-SVG 0.3 +// Project: https://github.com/adobe-webplatform/Snap.svg +// Definitions by: Lars Klein +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare function mina(a:number, A:number, b:number, B:number, get:Function, set:Function, easing?:Function):Object; +declare module mina { + export interface Mina { + id: string; + duration: Function; + easing: Function; + speed: Function; + status: Function; + stop: Function; + } + + export function backin(n:number):number; + export function backout(n:number):number; + export function bounce(n:number):number; + export function easein(n:number):number; + export function easeinout(n:number):number; + export function easeout(n:number):number; + export function elastic(n:number):number; + export function getById(id:string):Object; + export function linear(n:number):number; + export function time():number; +} + +declare function Snap(width:number,height:number):Snap.Paper; +declare function Snap(query:string):Snap.Paper; +declare function Snap(DOM:SVGElement):Snap.Paper; + +declare module Snap { + + export var filter:Filter; + export var path:Path; + + export function Matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; + export function Matrix(svgMatrix:SVGMatrix):Matrix; + + export function ajax(url:string,postData:string,callback:Function,scope?:Object):XMLHttpRequest; + export function ajax(url:string,postData:Object,callback:Function,scope?:Object):XMLHttpRequest; + export function ajax(url:string,callback:Function,scope?:Object):XMLHttpRequest; + export function format(token:string,json:Object):string; + export function fragment(varargs:any):Fragment; + export function getElementByPoint(x:number,y:number):Object; + export function is(o:any,type:string):boolean; + export function load(url:string,callback:Function,scope?:Object):void; + export function plugin(f:Function):void; + export function select(query:string):Snap.Element; + export function selectAll(query:string):any; + export function snapTo(values:Array,value:number,tolerance?:number):number; + + export function animate(from:number,to:number,setter:Function,duration:number,easing:Function,callback:Function):mina.Mina; + export function animate(from:Array,to:number,setter:Function,duration:number,easing:Function,callback:Function):mina.Mina; + export function animate(from:number,to:Array,setter:Function,duration:number,easing:Function,callback:Function):mina.Mina; + export function animate(from:Array,to:Array,setter:Function,duration:number,easing:Function,callback:Function):mina.Mina; + export function animation(attr:Object,duration:number,easing?:Function,callback?:Function):Object; + + export function color(clr:string):Object;export function getRGB(color:string):Object; + export function hsb(h:number,s:number,b:number):HSB; + export function hsl(h:number,s:number,l:number):HSL; + export function rgb(r:number,g:number,b:number):RGB; + export function hsb2rgb(h:number,s:number,v:number):RGB; + export function hsl2rgb(h:number,s:number,l:number):RGB; + export function rgb2hsb(r:number,g:number,b:number):HSB; + export function rgb2hsl(r:number,g:number,b:number):HSL; + + export function angle(x1:number,y1:number,x2:number,y2:number,x3?:number,y3?:number):number; + export function rad(deg:number):number; + export function deg(rad:number):number; + + export function parse(svg:string):Fragment; + export function parsePathString(pathString:string):Array; + export function parsePathString(pathString:Array):Array; + export function parseTransformString(TString:string):Array; + export function parseTransformString(TString:Array):Array; + + export interface RGB{ + r:number; + g:number; + b:number; + hex:string; + } + + export interface HSB{ + h:number; + s:number; + b:number; + } + export interface HSL{ + h:number; + s:number; + l:number; + } + + export interface BBox{ + cx:number; + cy:number; + h:number; + height:number; + path:number; + r0:number; + r1:number; + r2:number; + vb:string; + w:number; + width:number; + x2:number; + x:number; + y2:number; + y:number; + } + + export interface Element { + add():void; + addClass(value:string):Snap.Element; + after(el:Snap.Element):Snap.Element; + animate(attrs:Object,duration:number,easing?:Function,callback?:Function):Snap.Element; + animate(animation:any):Snap.Element; + append(el:Snap.Element):Snap.Element; + appendTo(el:Snap.Element):Snap.Element; + asPX(attr:string,value?:string):Snap.Element; + attr(params:Object):Snap.Element; + attr(param:string):string; + before(el:Snap.Element):Snap.Element; + clone():Snap.Element; + data(key:string,value?:any):any; + getBBox():BBox; + getPointAtLength(length:number):Object; + getSubpath(from:number,to:number):string; + getTotalLength():number; + hasClass(value:string):boolean; + inAnim():Object; + innerSVG():string; + insertAfter(el:Snap.Element):Snap.Element; + insertBefore(el:Snap.Element):Snap.Element; + marker(x:number,y:number,width:number,height:number,refX:number,refY:number):Snap.Element; + node:Element; + outerSVG():string; + parent():Snap.Element; + pattern(x:any,y:any,width:any,height:any):Snap.Element; + prepend(el:Snap.Element):Snap.Element; + prependTo(el:Snap.Element):Snap.Element; + remove():Snap.Element; + removeClass(value:string):Snap.Element; + removeData(key?:string):Snap.Element; + select(query:string):Snap.Element; + selectAll(query: string): Snap.Set; + selectAll(): Snap.Set; + stop():Snap.Element; + toDefs():Snap.Element; + toPattern(x:number,y:number,width:number,height:number):Object; + toPattern(x:string,y:string,width:string,height:string):Object; + toString():string; + toggleClass(value:string,flag:boolean):Snap.Element; + transform(tstr:string):any; + type:string; + use():Object; + + click(handler:Function):Snap.Element; + unclick(handler:Function):Snap.Element; + dblclick(handler:Function):Snap.Element; + undblclick(handler:Function):Snap.Element; + mousedown(handler:Function):Snap.Element; + unmousedown(handler:Function):Snap.Element; + mousemove(handler:Function):Snap.Element; + unmousemove(handler:Function):Snap.Element; + mouseout(handler:Function):Snap.Element; + unmouseout(handler:Function):Snap.Element; + mouseover(handler:Function):Snap.Element; + unmouseover(handler:Function):Snap.Element; + mouseup(handler:Function):Snap.Element; + unmouseup(handler:Function):Snap.Element; + touchstart(handler:Function):Snap.Element; + untouchstart(handler:Function):Snap.Element; + touchmove(handler:Function):Snap.Element; + untouchmove(handler:Function):Snap.Element; + touchend(handler:Function):Snap.Element; + untouchend(handler:Function):Snap.Element; + touchcancel(handler:Function):Snap.Element; + untouchcancel(handler:Function):Snap.Element; + hover(f_in:Function,f_out:Function,icontext?:Object,ocontext?:Object):Snap.Element; + unhover(f_in: Function, f_out: Function): Snap.Element; + drag(): void; + drag(onmove:Function,onstart:Function,onend:Function,mcontext?:Object,scontext?:Object,econtext?:Object):Snap.Element; + undrag():Snap.Element; + } + + export interface Fragment { + //TODO: The documentation says that selectAll returns a set, but the getting started guide + // uses .attr on the returned object. That's not supported by a set + select(query:string):Snap.Element; + selectAll(query:string):Snap.Set; + selectAll():Snap.Set; + } + + export interface Matrix { + add(a:number,b:number,c:number,d:number,e:number,f:number):void; + add(matrix:Matrix):void; + clone():Matrix; + determinant():number; + invert():Matrix; + rotate(a:number,x:number,y:number):void; + scale(x:number,y?:number,cx?:number,cy?:number):void; + split():Object; + toTransformString():string; + translate(x:number,y:number):void; + x(x:number,y:number):number; + y(x:number,y:number):number; + + } + + interface Paper extends Snap.Element { + + clear():void; + el(name:string, attr:Object):Snap.Element; + gradient(gradient:string):any; + g(varargs:any):Object; + group(el:any,...els:any[]):any; + mask(varargs:any):Object; + ptrn(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; + svg(x:number,y:number,width:number,height:number,vbx:number,vby:number,vbw:number,vbh:number):Object; + toString():string; + use(id?:string):Object; + use(id?:Snap.Element):Object; + + circle(x:number,y:number,r:number):Snap.Element; + ellipse(x:number,y:number,rx:number,ry:number):Snap.Element; + image(src:string,x:number,y:number,width:number,height:number):Snap.Element; + line(x1:number,y1:number,x2:number,y2:number):Snap.Element; + path(pathString?:string):Snap.Element; + polygon(varargs:any[]):Snap.Element; + polyline(varargs:any[]):Snap.Element; + rect(x:number,y:number,width:number,height:number,rx?:number,ry?:number):Snap.Element; + text(x:number,y:number,text:string):Snap.Element; + text(x:number,y:number,text:Array):Snap.Element; + } + + export interface Set { + animate(attrs:Object,duration:number,easing?:Function,callback?:Function):Snap.Element; + attr(params: Object): Snap.Element; + attr(param: string): string; + bind(attr: string, callback: Function): Snap.Set; + bind(attr:string,element:Snap.Element):Snap.Set; + bind(attr:string,element:Snap.Element,eattr:string):Snap.Set; + clear():Snap.Set; + exclude(element:Snap.Element):boolean; + forEach(callback:Function,thisArg?:Object):Snap.Set; + pop():Snap.Element; + push(el:Snap.Element):Snap.Element; + push(els:Snap.Element[]):Snap.Element; + splice(index:number,count:number,insertion?:Object[]):Snap.Element[]; + } + + interface Filter { + blur(x:number,y?:number):string; + brightness(amount:number):string; + contrast(amount:number):string; + grayscale(amount:number):string; + hueRotate(angle:number):string; + invert(amount:number):string; + saturate(amount:number):string; + sepia(amount:number):string; + shadow(dx:number,dy:number,blur?:number,color?:string,opacity?:number):string; + } + + interface Path { + bezierBBox(...args:number[]):Object; + bezierBBox(bez:Array):Object; + findDotsAtSegment(p1x:number,p1y:number,c1x:number, + c1y:number,c2x:number,c2y:number, + p2x:number,p2y:number,t:number):Object; + getBBox(path:string):Object; + getPointAtLength(path:string,length:number):Object; + getSubpath(path:string,from:number,to:number):string; + getTotalLength(path:string):number; + intersection(path1:string,path2:string):Array; + isBBoxIntersect(bbox1:string,bbox2:string):boolean + isPointInside(path:string,x:number,y:number):boolean; + isPointInsideBBox(bbox:string,x:string,y:string):boolean; + map(path:string,matrix:Snap.Matrix):string; + map(path:string,matrix:Object):string; + toAbsolute(path:string):Array; + toCubic(pathString:string):Array; + toCubic(pathString:Array):Array; + toRelative(path:string):Array; + } +} diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 02179ff158..111a7fc9be 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -3674,7 +3674,7 @@ declare module THREE { /** * Adds v to this vector. */ - add(a: Object): Vector3; + add(a: Vector): Vector3; addScalar(s: number): Vector3; /** @@ -5759,4 +5759,4 @@ declare module THREE { declare module 'three' { export=THREE; -} \ No newline at end of file +} diff --git a/timezonecomplete/timezonecomplete-1.9.0.d.ts b/timezonecomplete/timezonecomplete-1.9.0.d.ts new file mode 100644 index 0000000000..0490ee94dd --- /dev/null +++ b/timezonecomplete/timezonecomplete-1.9.0.d.ts @@ -0,0 +1,1207 @@ +// Type definitions for timezonecomplete 1.9.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.9.0' { + import basics = require("__timezonecomplete/basics"); + export import TimeUnit = basics.TimeUnit; + export import WeekDay = basics.WeekDay; + export import timeUnitToMilliseconds = basics.timeUnitToMilliseconds; + export import isLeapYear = basics.isLeapYear; + export import daysInMonth = basics.daysInMonth; + export import daysInYear = basics.daysInYear; + export import firstWeekDayOfMonth = basics.firstWeekDayOfMonth; + export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth; + export import weekDayOnOrAfter = basics.weekDayOnOrAfter; + export import weekDayOnOrBefore = basics.weekDayOnOrBefore; + export import weekNumber = basics.weekNumber; + export import weekOfMonth = basics.weekOfMonth; + export import dayOfYear = basics.dayOfYear; + export import secondOfDay = basics.secondOfDay; + import datetime = require("__timezonecomplete/datetime"); + export import DateTime = datetime.DateTime; + import duration = require("__timezonecomplete/duration"); + 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; + import globals = require("__timezonecomplete/globals"); + export import min = globals.min; + export import max = globals.max; +} + +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, + } + /** + * Approximate number of milliseconds for a time unit. + * A day is assumed to have 24 hours, a month is assumed to equal 30 days + * and a year is set to 365 days. + * + * @param unit Time unit e.g. TimeUnit.Month + * @returns The number of milliseconds. + */ + export function timeUnitToMilliseconds(unit: TimeUnit): number; + /** + * @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 first instance of the given weekday in the given month + * + * @param year The year + * @param month the month 1-12 + * @param weekDay the desired week day + * + * @return the first occurrence of the week day in the month + */ + export function firstWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; + /** + * Returns the day-of-month that is on the given weekday and which is >= the given day. + * Throws if the month has no such day. + */ + 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; + /** + * The week of this month. There is no official standard for this, + * but we assume the same rules for the weekNumber (i.e. + * week 1 is the week that has the 4th day of the month in it) + * + * @param year The year + * @param month The month [1-12] + * @param day The day [1-31] + * @return Week number [1-5] + */ + export function weekOfMonth(year: number, month: number, day: number): number; + /** + * The ISO 8601 week number for the given date. Week 1 is the week + * that has January 4th in it, and it starts on Monday. + * See https://en.wikipedia.org/wiki/ISO_week_date + * + * @param year Year e.g. 1988 + * @param month Month 1-12 + * @param day Day of month 1-31 + * + * @return Week number 1-53 + */ + export function weekNumber(year: number, month: number, day: number): number; + /** + * Convert a unix milli timestamp into a TimeT structure. + * This does NOT take leap seconds into account. + */ + 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; + /** + * N-th second in the day, counting from 0 + */ + export function secondOfDay(hour: number, minute: number, second: number): number; + /** + * Basic representation of a date and time + */ + 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; + /** + * Zone name abbreviation at this time + * @param dstDependent (default true) set to false for a DST-agnostic abbreviation + * @return The abbreviation + */ + zoneAbbreviation(dstDependent?: boolean): string; + /** + * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. + */ + 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; + /** + * Returns the day number within the year: Jan 1st has number 0, + * Jan 2nd has number 1 etc. + * + * @return the day-of-year [0-366] + */ + dayOfYear(): number; + /** + * The ISO 8601 week number. Week 1 is the week + * that has January 4th in it, and it starts on Monday. + * See https://en.wikipedia.org/wiki/ISO_week_date + * + * @return Week number [1-53] + */ + weekNumber(): number; + /** + * The week of this month. There is no official standard for this, + * but we assume the same rules for the weekNumber (i.e. + * week 1 is the week that has the 4th day of the month in it) + * + * @return Week number [1-5] + */ + weekOfMonth(): number; + /** + * Returns the number of seconds that have passed on the current day + * Does not consider leap seconds + * + * @return seconds [0-86399] + */ + secondOfDay(): number; + /** + * @return Milliseconds since 1970-01-01T00:00:00.000Z + */ + 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; + /** + * Returns the UTC day number within the year: Jan 1st has number 0, + * Jan 2nd has number 1 etc. + * + * @return the day-of-year [0-366] + */ + utcDayOfYear(): number; + /** + * @return The UTC milliseconds 0-999 + */ + utcMillisecond(): number; + /** + * @return the UTC day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + utcWeekDay(): basics.WeekDay; + /** + * The ISO 8601 UTC week number. Week 1 is the week + * that has January 4th in it, and it starts on Monday. + * See https://en.wikipedia.org/wiki/ISO_week_date + * + * @return Week number [1-53] + */ + utcWeekNumber(): number; + /** + * The week of this month. There is no official standard for this, + * but we assume the same rules for the weekNumber (i.e. + * week 1 is the week that has the 4th day of the month in it) + * + * @return Week number [1-5] + */ + utcWeekOfMonth(): number; + /** + * Returns the number of seconds that have passed on the current day + * Does not consider leap seconds + * + * @return seconds [0-86399] + */ + utcSecondOfDay(): number; + /** + * Convert this date to the given time zone (in-place). + * Throws if this date does not have a time zone. + * @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; + /** + * @return The minimum of this and other + */ + min(other: DateTime): DateTime; + /** + * @return The maximum of this and other + */ + max(other: DateTime): DateTime; + /** + * 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; + /** + * Return a string representation of the DateTime according to the + * specified format. The format is implemented as the LDML standard + * (http://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns) + * + * @param formatString The format specification (e.g. "dd/MM/yyyy HH:mm:ss") + * @return The string representation of this DateTime + */ + format(formatString: string): 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; + /** + * The valueOf() method returns the primitive value of the specified object. + */ + valueOf(): any; + /** + * Modified ISO 8601 format string in UTC without time zone info + */ + toUtcString(): string; + } +} + +declare module '__timezonecomplete/duration' { + import basics = require("__timezonecomplete/basics"); + /** + * 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); + /** + * Construct a duration from an amount and a time unit. + * @param amount Number of units + * @param unit A time unit i.e. TimeUnit.Second, TimeUnit.Hour etc. + */ + constructor(amount: number, unit: basics.TimeUnit); + /** + * @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 <= other) + */ + lessEqual(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 True iff this >= other + */ + greaterEqual(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; + /** + * The valueOf() method returns the primitive value of the specified object. + */ + valueOf(): any; + } +} + +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; + /** + * Checks whether the given date is on a period boundary + * (expensive!) + */ + isBoundary(occurrence: datetime.DateTime): boolean; + /** + * 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 Full year + * @param month Month 1-12 (note this deviates from JavaScript date) + * @param day Day of month 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 + * @param millisecond Millisecond 0-999 + * + * @return the offset of this time zone with respect to UTC at the given time, in minutes. + */ + offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * 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; + /** + * Zone abbreviation at given UTC timestamp e.g. CEST for Central European Summer Time. + * + * @param year Full year + * @param month Month 1-12 (note this deviates from JavaScript date) + * @param day Day of month 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 + * @param millisecond Millisecond 0-999 + * @param dstDependent (default true) set to false for a DST-agnostic abbreviation + * + * @return "local" for local timezone, the offset for an offset zone, or the abbreviation for a proper zone. + */ + abbreviationForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, dstDependent?: boolean): string; + /** + * Normalizes non-existing local times by adding a forward offset change. + * During a forward standard offset change or DST offset change, some amount of + * 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; + } +} + +declare module '__timezonecomplete/globals' { + import datetime = require("__timezonecomplete/datetime"); + import duration = require("__timezonecomplete/duration"); + /** + * Returns the minimum of two DateTimes + */ + export function min(d1: datetime.DateTime, d2: datetime.DateTime): datetime.DateTime; + /** + * Returns the minimum of two Durations + */ + export function min(d1: duration.Duration, d2: duration.Duration): duration.Duration; + /** + * Returns the maximum of two DateTimes + */ + export function max(d1: datetime.DateTime, d2: datetime.DateTime): datetime.DateTime; + /** + * Returns the maximum of two Durations + */ + export function max(d1: duration.Duration, d2: duration.Duration): duration.Duration; +} + diff --git a/timezonecomplete/timezonecomplete-tests-1.9.0.ts b/timezonecomplete/timezonecomplete-tests-1.9.0.ts new file mode 100644 index 0000000000..1e05cf7dc1 --- /dev/null +++ b/timezonecomplete/timezonecomplete-tests-1.9.0.ts @@ -0,0 +1,205 @@ +/// + +import tc = require("timezonecomplete-1.9.0"); + +var b: boolean; +var n: number; +var s: string; +var w: tc.WeekDay; + +n = tc.timeUnitToMilliseconds(tc.TimeUnit.Month); +b = tc.isLeapYear(2014); +n = tc.daysInMonth(2014, 10); +n = tc.daysInYear(2014); +n = tc.dayOfYear(2014, 1, 2); +w = tc.firstWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); +w = tc.lastWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); +n = tc.weekDayOnOrAfter(2014, 1, 14, tc.WeekDay.Monday); +n = tc.weekDayOnOrBefore(2014, 1, 14, tc.WeekDay.Monday); +n = tc.secondOfDay(13, 59, 59); +n = tc.weekOfMonth(2014, 1, 1); + +// DURATION + +var d: tc.Duration; +var d1: tc.Duration = tc.Duration.hours(24); +var d2: tc.Duration = tc.Duration.minutes(24); +var d3: tc.Duration = tc.Duration.seconds(24); +var d4: tc.Duration = tc.Duration.milliseconds(24); +var d5: tc.Duration = new tc.Duration(24); +var d6: tc.Duration = new tc.Duration("00:01"); +var d7: tc.Duration = d6.clone(); +var d8: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second); + +n = d7.wholeHours(); +n = d7.hours(); +n = d7.minutes(); +n = d7.minute(); +n = d7.seconds(); +n = d7.second(); +n = d7.milliseconds(); +n = d7.millisecond(); +s = d7.sign(); +b = d7.lessThan(d6); +b = d7.greaterThan(d6); +d = d7.min(d6); +d = d7.max(d6); +d = d7.multiply(3); +d = d7.divide(0.3); +d = d7.add(d6); +d = d7.sub(d6); +s = d7.toString(); + +// TIMEZONE + +var t: tc.TimeZone; +var k: tc.TimeZoneKind; + +t = tc.TimeZone.local(); +t = tc.TimeZone.utc(); +t = tc.TimeZone.zone(2); +t = tc.TimeZone.zone("+01:00"); +s = t.name(); +k = t.kind(); +b = t.equals(t); +b = t.isUtc(); +n = t.offsetForUtc(2014, 1, 1, 13, 0, 5, 123); +n = t.offsetForZone(2014, 1, 1, 13, 0, 5, 123); +n = t.offsetForUtcDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.Get); +n = t.offsetForZoneDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.GetUTC); +s = t.toString(); +s = tc.TimeZone.offsetToString(2); +n = tc.TimeZone.stringToOffset("+00:01"); + +// REALTIMESOURCE + +var date: Date = (new tc.RealTimeSource()).now(); + +// DATETIME + +var dt: tc.DateTime; + +var ts: tc.TimeSource = tc.DateTime.timeSource; + +dt = tc.DateTime.nowLocal(); +dt = tc.DateTime.nowUtc(); +dt = tc.DateTime.now(tc.TimeZone.local()); +dt = new tc.DateTime(); +dt = new tc.DateTime("2014-01-01T13:05:01.123 UTC"); +dt = new tc.DateTime("2014-01-01T13:05:01.123", tc.TimeZone.utc()); +dt = new tc.DateTime(date, tc.DateFunctions.Get); +dt = new tc.DateTime(date, tc.DateFunctions.Get, tc.TimeZone.utc()); +dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123); +dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123, tc.TimeZone.utc()); +dt = new tc.DateTime(89949284); +dt = new tc.DateTime(89949284, tc.TimeZone.utc()); +dt = dt.clone(); +t = dt.zone(); +n = dt.offset(); +n = dt.year(); +n = dt.month(); +n = dt.day(); +n = dt.hour(); +n = dt.minute(); +n = dt.second(); +n = dt.weekNumber(); +n = dt.weekOfMonth(); +n = dt.secondOfDay(); +n = dt.dayOfYear(); +n = dt.millisecond(); +n = dt.unixUtcMillis(); +n = dt.utcYear(); +n = dt.utcMonth(); +n = dt.utcDay(); +n = dt.utcHour(); +n = dt.utcMinute(); +n = dt.utcSecond(); +n = dt.utcMillisecond(); +n = dt.utcWeekNumber(); +n = dt.utcWeekOfMonth(); +n = dt.utcSecondOfDay(); +n = dt.utcDayOfYear(); +s = dt.format("%Y-%m-%d"); +dt.convert(tc.TimeZone.local()); +dt = dt.toZone(tc.TimeZone.utc()); +date = dt.toDate(); +dt = dt.add(tc.Duration.seconds(2)); +dt = dt.add(2, tc.TimeUnit.Year); +dt = dt.add(2, tc.TimeUnit.Month); +dt = dt.add(2, tc.TimeUnit.Week); +dt = dt.add(2, tc.TimeUnit.Day); +dt = dt.add(2, tc.TimeUnit.Hour); +dt = dt.add(2, tc.TimeUnit.Minute); +dt = dt.add(2, tc.TimeUnit.Second); +dt = dt.addLocal(2, tc.TimeUnit.Second); +dt = dt.sub(tc.Duration.seconds(2)); +dt = dt.sub(2, tc.TimeUnit.Year); +dt = dt.sub(2, tc.TimeUnit.Month); +dt = dt.sub(2, tc.TimeUnit.Week); +dt = dt.sub(2, tc.TimeUnit.Day); +dt = dt.sub(2, tc.TimeUnit.Hour); +dt = dt.sub(2, tc.TimeUnit.Minute); +dt = dt.sub(2, tc.TimeUnit.Second); +dt = dt.subLocal(2, tc.TimeUnit.Second); +d = dt.diff(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.lessThan(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.lessEqual(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.greaterThan(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.greaterEqual(new tc.DateTime(9289234, tc.TimeZone.local())); +dt = dt.min(new tc.DateTime(9289234, tc.TimeZone.local())); +dt = dt.max(new tc.DateTime(9289234, tc.TimeZone.local())); +s = dt.toIsoString(); +s = dt.toString(); +s = dt.toUtcString(); + +var wd: tc.WeekDay; +wd = dt.weekDay(); +wd = dt.utcWeekDay(); + +// PERIOD + +s = tc.periodDstToString(tc.PeriodDst.RegularIntervals); +s = tc.periodDstToString(tc.PeriodDst.RegularLocalTime); + +var p: tc.Period; + +p = new tc.Period(tc.DateTime.nowLocal(), 1, tc.TimeUnit.Hour, tc.PeriodDst.RegularLocalTime); +dt = p.start(); +n = p.amount(); +var tu: tc.TimeUnit = p.unit(); +var pd: tc.PeriodDst = p.dst(); +dt = p.findFirst(tc.DateTime.nowLocal()); +dt = p.findNext(dt); +s = p.toIsoString(); +s = p.toString(); +b = p.isBoundary(dt); + + +// GLOBALS +d = tc.min(tc.Duration.seconds(2), tc.Duration.seconds(3)); +d = tc.max(tc.Duration.seconds(2), tc.Duration.seconds(3)); + +dt = tc.min(new tc.DateTime(2), new tc.DateTime(3)); +dt = tc.max(new tc.DateTime(2), new tc.DateTime(3)); + + + + + + + + + + + + + + + + + + + + + + diff --git a/timezonecomplete/timezonecomplete-tests.ts b/timezonecomplete/timezonecomplete-tests.ts index 19dcd84c7e..cb07832a6e 100644 --- a/timezonecomplete/timezonecomplete-tests.ts +++ b/timezonecomplete/timezonecomplete-tests.ts @@ -26,10 +26,14 @@ var d1: tc.Duration = tc.Duration.hours(24); var d2: tc.Duration = tc.Duration.minutes(24); var d3: tc.Duration = tc.Duration.seconds(24); var d4: tc.Duration = tc.Duration.milliseconds(24); -var d5: tc.Duration = new tc.Duration(24); -var d6: tc.Duration = new tc.Duration("00:01"); -var d7: tc.Duration = d6.clone(); -var d8: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second); +var d5: tc.Duration = tc.hours(24); +var d6: tc.Duration = tc.minutes(24); +var d7: tc.Duration = tc.seconds(24); +var d8: tc.Duration = tc.milliseconds(24); +var d9: tc.Duration = new tc.Duration(24); +var d10: tc.Duration = new tc.Duration("00:01"); +var d11: tc.Duration = d6.clone(); +var d12: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second); n = d7.wholeHours(); n = d7.hours(); @@ -59,10 +63,16 @@ t = tc.TimeZone.local(); t = tc.TimeZone.utc(); t = tc.TimeZone.zone(2); t = tc.TimeZone.zone("+01:00"); +t = tc.local(); +t = tc.utc(); +t = tc.zone(2); +t = tc.zone("+01:00"); +t = tc.zone("Europe/Amsterdam", false); s = t.name(); k = t.kind(); b = t.equals(t); b = t.isUtc(); +b = t.dst(); n = t.offsetForUtc(2014, 1, 1, 13, 0, 5, 123); n = t.offsetForZone(2014, 1, 1, 13, 0, 5, 123); n = t.offsetForUtcDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.Get); @@ -84,6 +94,9 @@ var ts: tc.TimeSource = tc.DateTime.timeSource; dt = tc.DateTime.nowLocal(); dt = tc.DateTime.nowUtc(); dt = tc.DateTime.now(tc.TimeZone.local()); +dt = tc.nowLocal(); +dt = tc.nowUtc(); +dt = tc.now(tc.TimeZone.local()); dt = new tc.DateTime(); dt = new tc.DateTime("2014-01-01T13:05:01.123 UTC"); dt = new tc.DateTime("2014-01-01T13:05:01.123", tc.TimeZone.utc()); diff --git a/timezonecomplete/timezonecomplete.d.ts b/timezonecomplete/timezonecomplete.d.ts index 4bf2a6a28a..c91f138c61 100644 --- a/timezonecomplete/timezonecomplete.d.ts +++ b/timezonecomplete/timezonecomplete.d.ts @@ -1,4 +1,4 @@ -// Type definitions for timezonecomplete 1.9.0 +// Type definitions for timezonecomplete 1.10.0 // Project: https://github.com/SpiritIT/timezonecomplete // Definitions by: Rogier Schouten // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -22,8 +22,15 @@ declare module 'timezonecomplete' { export import secondOfDay = basics.secondOfDay; import datetime = require("__timezonecomplete/datetime"); export import DateTime = datetime.DateTime; + export import now = datetime.now; + export import nowLocal = datetime.nowLocal; + export import nowUtc = datetime.nowUtc; import duration = require("__timezonecomplete/duration"); export import Duration = duration.Duration; + export import hours = duration.hours; + export import minutes = duration.minutes; + export import seconds = duration.seconds; + export import milliseconds = duration.milliseconds; import javascript = require("__timezonecomplete/javascript"); export import DateFunctions = javascript.DateFunctions; import period = require("__timezonecomplete/period"); @@ -37,6 +44,9 @@ declare module 'timezonecomplete' { export import NormalizeOption = timezone.NormalizeOption; export import TimeZoneKind = timezone.TimeZoneKind; export import TimeZone = timezone.TimeZone; + export import local = timezone.local; + export import utc = timezone.utc; + export import zone = timezone.zone; import globals = require("__timezonecomplete/globals"); export import min = globals.min; export import max = globals.max; @@ -299,9 +309,22 @@ declare module '__timezonecomplete/basics' { declare module '__timezonecomplete/datetime' { import basics = require("__timezonecomplete/basics"); import duration = require("__timezonecomplete/duration"); - import javascript = require("__timezonecomplete/javascript"); import timesource = require("__timezonecomplete/timesource"); + import javascript = require("__timezonecomplete/javascript"); import timezone = require("__timezonecomplete/timezone"); + /** + * Current date+time in local time + */ + export function nowLocal(): DateTime; + /** + * Current date+time in UTC time + */ + export function nowUtc(): DateTime; + /** + * Current date+time in the given time zone + * @param timeZone The desired time zone (optional, defaults to UTC). + */ + export function now(timeZone?: timezone.TimeZone): DateTime; /** * DateTime class which is time zone-aware * and which can be mocked for testing purposes. @@ -314,18 +337,18 @@ declare module '__timezonecomplete/datetime' { */ static timeSource: timesource.TimeSource; /** - * Current date+time in local time (derived from DateTime.timeSource.now()). + * Current date+time in local time */ static nowLocal(): DateTime; /** - * Current date+time in UTC time (derived from DateTime.timeSource.now()). + * Current date+time in UTC time */ static nowUtc(): DateTime; /** - * Current date+time in the given time zone (derived from DateTime.timeSource.now()). - * @param timeZone The desired time zone. + * Current date+time in the given time zone + * @param timeZone The desired time zone (optional, defaults to UTC). */ - static now(timeZone: timezone.TimeZone): DateTime; + static now(timeZone?: timezone.TimeZone): DateTime; /** * Constructor. Creates current time in local timezone. */ @@ -673,6 +696,30 @@ declare module '__timezonecomplete/datetime' { declare module '__timezonecomplete/duration' { import basics = require("__timezonecomplete/basics"); + /** + * Construct a time duration + * @param n Number of hours (may be fractional or negative) + * @return A duration of n hours + */ + export function hours(n: number): Duration; + /** + * Construct a time duration + * @param n Number of minutes (may be fractional or negative) + * @return A duration of n minutes + */ + export function minutes(n: number): Duration; + /** + * Construct a time duration + * @param n Number of seconds (may be fractional or negative) + * @return A duration of n seconds + */ + export function seconds(n: number): Duration; + /** + * Construct a time duration + * @param n Number of milliseconds (may be fractional or negative) + * @return A duration of n milliseconds + */ + export function milliseconds(n: number): Duration; /** * Time duration. Create one e.g. like this: var d = Duration.hours(1). * Note that time durations do not take leap seconds etc. into account: @@ -681,25 +728,25 @@ declare module '__timezonecomplete/duration' { export class Duration { /** * Construct a time duration - * @param n Number of hours + * @param n Number of hours (may be fractional or negative) * @return A duration of n hours */ static hours(n: number): Duration; /** * Construct a time duration - * @param n Number of minutes + * @param n Number of minutes (may be fractional or negative) * @return A duration of n minutes */ static minutes(n: number): Duration; /** * Construct a time duration - * @param n Number of seconds + * @param n Number of seconds (may be fractional or negative) * @return A duration of n seconds */ static seconds(n: number): Duration; /** * Construct a time duration - * @param n Number of milliseconds + * @param n Number of milliseconds (may be fractional or negative) * @return A duration of n milliseconds */ static milliseconds(n: number): Duration; @@ -993,6 +1040,35 @@ declare module '__timezonecomplete/timesource' { declare module '__timezonecomplete/timezone' { import javascript = require("__timezonecomplete/javascript"); + /** + * The local time zone for a given date as per OS settings. Note that time zones are cached + * so you don't necessarily get a new object each time. + */ + export function local(): TimeZone; + /** + * Coordinated Universal Time zone. Note that time zones are cached + * so you don't necessarily get a new object each time. + */ + export function utc(): TimeZone; + /** + * @param offset offset w.r.t. UTC in minutes, e.g. 90 for +01:30. Note that time zones are cached + * so you don't necessarily get a new object each time. + * @returns a time zone with the given fixed offset + */ + export function zone(offset: number): TimeZone; + /** + * Time zone for an offset string or an IANA time zone string. Note that time zones are cached + * so you don't necessarily get a new object each time. + * @param s Empty string for no time zone (null is returned), + * "localtime" for local time, + * a TZ database time zone name (e.g. Europe/Amsterdam), + * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + * @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for + * "localtime", timezonecomplete will adhere to the computer settings, the DST flag + * does not have any effect. + */ + export function zone(name: string, dst?: boolean): TimeZone; /** * The type of time zone */ @@ -1046,29 +1122,37 @@ declare module '__timezonecomplete/timezone' { */ static utc(): TimeZone; /** - * Returns a time zone object from the cache. If it does not exist, it is created. - * @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30 + * Time zone with a fixed offset + * @param offset offset w.r.t. UTC in minutes, e.g. 90 for +01:30 */ static zone(offset: number): TimeZone; /** - * Returns a time zone object from the cache. If it does not exist, it is created. - * @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam) - * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: - * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + * Time zone for an offset string or an IANA time zone string. Note that time zones are cached + * so you don't necessarily get a new object each time. + * @param s Empty string for no time zone (null is returned), + * "localtime" for local time, + * a TZ database time zone name (e.g. Europe/Amsterdam), + * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + * @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for + * "localtime", timezonecomplete will adhere to the computer settings, the DST flag + * does not have any effect. */ - static zone(s: string): TimeZone; + static zone(s: string, dst?: boolean): TimeZone; /** * Do not use this constructor, use the static * TimeZone.zone() method instead. * @param name NORMALIZED name, assumed to be correct + * @param dst Adhere to Daylight Saving Time if applicable, ignored for local time and fixed offsets */ - constructor(name: string); + constructor(name: string, dst?: boolean); /** * The time zone identifier. Can be an offset "-01:30" or an * IANA time zone name "Europe/Amsterdam", or "localtime" for * the local time zone. */ name(): string; + dst(): boolean; /** * The kind of time zone (Local/Offset/Proper) */