From a958c78dd334f8edd333d5a09ca57c6422fa9b55 Mon Sep 17 00:00:00 2001 From: Chip Wasson Date: Sun, 18 Nov 2018 16:57:44 -0700 Subject: [PATCH] Twix - Add missing 'Hiding Things' properties to TwixFormatOptions interface (#30426) * Add missing params to TwixFormatOptions * Add examples to twix tests * Add Twix hideYear --- types/twix/index.d.ts | 7 +++++-- types/twix/twix-tests.ts | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/types/twix/index.d.ts b/types/twix/index.d.ts index 5b37054eb9..175ee1f0aa 100644 --- a/types/twix/index.d.ts +++ b/types/twix/index.d.ts @@ -23,6 +23,9 @@ export interface TwixFormatOptions { allDay?: any; // boolean | string explicitAllDay?: boolean; lastNightEndsAt?: number; + hideTime?: boolean; + hideDate?: boolean; + hideYear?: boolean; } export interface TwixParseAndFormatOptions extends TwixFormatOptions { @@ -61,8 +64,8 @@ export interface Twix { overlaps(other: Twix): boolean; engulfs(other: Twix): boolean; equals(other: Twix): boolean; - union(other: Twix): Twix; - intersection(other: Twix): Twix; + union(other: Twix): Twix; + intersection(other: Twix): Twix; xor(other: Twix): Twix[]; difference(other: Twix): Twix[]; diff --git a/types/twix/twix-tests.ts b/types/twix/twix-tests.ts index dc4ba2c878..751e501ef0 100644 --- a/types/twix/twix-tests.ts +++ b/types/twix/twix-tests.ts @@ -222,4 +222,24 @@ t.format(); //=> Jan 25, 1982, 9:30 AM - 1:30 PM t.isSame("day"); //=> true t.humanizeLength(); //=> "4 hours" -t.count("days"); //=> 1 \ No newline at end of file +t.count("days"); //=> 1 + + +var t = moment("2012-05-25T8:00").twix("2012-05-27T17:00"); + +t.format({ hideTime: true }); //=> May 25 - 27, 2012 + + +var t = moment("2012-05-25T8:00").twix("2012-05-25T17:00"); + +t.format({ hideDate: true }); //=> 8 AM - 5 PM + + +var t = moment("2012-01-25").twix("2012-01-25", { allDay: true }); + +t.format({ hideDate: true }); //=> All day + + +var t = moment("2012-05-25").twix("2012-05-27"); + +t.format({ hideYear: true }); //=> May 25 - May 27 \ No newline at end of file