Twix - Add missing 'Hiding Things' properties to TwixFormatOptions interface (#30426)

* Add missing params to TwixFormatOptions

* Add examples to twix tests

* Add Twix hideYear
This commit is contained in:
Chip Wasson 2018-11-18 16:57:44 -07:00 committed by Pranav Senthilnathan
parent 15b8963cea
commit a958c78dd3
2 changed files with 26 additions and 3 deletions

View File

@ -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[];

View File

@ -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
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