From 379e9c0805bca2d0361dc6e9b5206801471fd709 Mon Sep 17 00:00:00 2001 From: Sammy Chu Date: Wed, 20 May 2015 13:16:08 +0800 Subject: [PATCH] update moment-timezone constructor definition, to align the constructor definition of moment --- moment-timezone/moment-timezone-tests.ts | 32 ++++++++++++++++++++++-- moment-timezone/moment-timezone.d.ts | 18 +++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/moment-timezone/moment-timezone-tests.ts b/moment-timezone/moment-timezone-tests.ts index 6e818c742..b7624b63a 100644 --- a/moment-timezone/moment-timezone-tests.ts +++ b/moment-timezone/moment-timezone-tests.ts @@ -12,14 +12,42 @@ var d = moment.tz("May 12th 2014 8PM", "MMM Do YYYY hA", true, "America/Toronto" a.tz(); -var arr = [2013, 5, 1], +var num = 1367337600000, + arr = [2013, 5, 1], str = "2013-12-01", - obj = { year : 2013, month : 5, day : 1 }; + date = new Date(2013, 4, 1), + mo = moment([2013, 4, 1]), + obj = { year : 2013, month : 5, day : 1 }, + format = "YYYY-MM-DD", + formats = ["YYYY-MM-DD", "YYYY/MM/DD"], + formatsIncludingSpecial = ["YYYY-MM-DD", moment.ISO_8601], + language = "en"; +moment.tz(); moment.tz("America/Los_Angeles"); +moment.tz(num, "America/Los_Angeles"); moment.tz(arr, "America/Los_Angeles"); moment.tz(str, "America/Los_Angeles"); +moment.tz(str, format, "America/Los_Angeles"); +moment.tz(str, format, true, "America/Los_Angeles"); +moment.tz(str, format, language, "America/Los_Angeles"); +moment.tz(str, format, language, true, "America/Los_Angeles"); +moment.tz(str, formats, "America/Los_Angeles"); +moment.tz(str, formats, true, "America/Los_Angeles"); +moment.tz(str, formats, language, "America/Los_Angeles"); +moment.tz(str, formats, language, true, "America/Los_Angeles"); +moment.tz(str, moment.ISO_8601, "America/Los_Angeles"); +moment.tz(str, moment.ISO_8601, true, "America/Los_Angeles"); +moment.tz(str, moment.ISO_8601, language, "America/Los_Angeles"); +moment.tz(str, moment.ISO_8601, language, true, "America/Los_Angeles"); +moment.tz(str, formatsIncludingSpecial, "America/Los_Angeles"); +moment.tz(str, formatsIncludingSpecial, true, "America/Los_Angeles"); +moment.tz(str, formatsIncludingSpecial, language, "America/Los_Angeles"); +moment.tz(str, formatsIncludingSpecial, language, true, "America/Los_Angeles"); + +moment.tz(date, "America/Los_Angeles"); +moment.tz(mo, "America/Los_Angeles"); moment.tz(obj, "America/Los_Angeles"); moment.tz.zone('America/Los_Angeles').abbr(1403465838805); diff --git a/moment-timezone/moment-timezone.d.ts b/moment-timezone/moment-timezone.d.ts index 02d72ac2e..ef9a41142 100644 --- a/moment-timezone/moment-timezone.d.ts +++ b/moment-timezone/moment-timezone.d.ts @@ -28,11 +28,25 @@ interface MomentZone { } interface MomentTimezone { - (timezone: string): moment.Moment; (date: number, timezone: string): moment.Moment; (date: number[], timezone: string): moment.Moment; + (date: string, timezone: string): moment.Moment; (date: string, format: string, timezone: string): moment.Moment; - (date: string, format: string, useStrict: boolean, timezone: string): moment.Moment; + (date: string, format: string, strict: boolean, timezone: string): moment.Moment; + (date: string, format: string, language: string, timezone: string): moment.Moment; + (date: string, format: string, language: string, strict: boolean, timezone: string): moment.Moment; + (date: string, formats: string[], timezone: string): moment.Moment; + (date: string, formats: string[], strict: boolean, timezone: string): moment.Moment; + (date: string, formats: string[], language: string, timezone: string): moment.Moment; + (date: string, formats: string[], language: string, strict: boolean, timezone: string): moment.Moment; + (date: string, specialFormat: () => void, timezone: string): moment.Moment; + (date: string, specialFormat: () => void, strict: boolean, timezone: string): moment.Moment; + (date: string, specialFormat: () => void, language: string, timezone: string): moment.Moment; + (date: string, specialFormat: () => void, language: string, strict: boolean, timezone: string): moment.Moment; + (date: string, formatsIncludingSpecial: any[], timezone: string): moment.Moment; + (date: string, formatsIncludingSpecial: any[], strict: boolean, timezone: string): moment.Moment; + (date: string, formatsIncludingSpecial: any[], language: string, timezone: string): moment.Moment; + (date: string, formatsIncludingSpecial: any[], language: string, strict: boolean, timezone: string): moment.Moment; (date: Date, timezone: string): moment.Moment; (date: moment.Moment, timezone: string): moment.Moment; (date: Object, timezone: string): moment.Moment;