Comparing version 0.1.2 to 0.1.3
@@ -35,2 +35,3 @@ (function() { | ||
showDate: true, | ||
showDayOfWeek: false, | ||
twentyFourHour: false, | ||
@@ -40,2 +41,3 @@ implicitMinutes: true, | ||
monthFormat: "MMM", | ||
weekdayFormat: "ddd", | ||
dayFormat: "D", | ||
@@ -70,3 +72,3 @@ meridiemFormat: "A", | ||
pre: ", ", | ||
slot: 3 | ||
slot: 4 | ||
}); | ||
@@ -80,3 +82,3 @@ } | ||
}, | ||
slot: 1, | ||
slot: 2, | ||
pre: " " | ||
@@ -91,3 +93,3 @@ }); | ||
}, | ||
slot: 1, | ||
slot: 2, | ||
pre: " " | ||
@@ -102,6 +104,16 @@ }); | ||
}, | ||
slot: 2, | ||
slot: 3, | ||
pre: " " | ||
}); | ||
} | ||
if (needDate && options.showDayOfWeek) { | ||
fs.push({ | ||
name: "day of week", | ||
fn: function(date) { | ||
return date.format(options.weekdayFormat); | ||
}, | ||
pre: " ", | ||
slot: 1 | ||
}); | ||
} | ||
if (options.groupMeridiems && !options.twentyFourHour && !this.allDay) { | ||
@@ -113,3 +125,3 @@ fs.push({ | ||
}, | ||
slot: 5, | ||
slot: 6, | ||
pre: options.spaceBeforeMeridiem ? " " : "" | ||
@@ -123,15 +135,11 @@ }); | ||
var str; | ||
if (date.minutes() === 0 && options.implicitMinutes && !options.twentyFourHour) { | ||
return date.format(options.hourFormat); | ||
} else { | ||
str = date.format("" + options.hourFormat + ":" + options.minuteFormat); | ||
if (!options.groupMeridiems && !options.twentyFourHour) { | ||
if (options.spaceBeforeMeridiem) str += " "; | ||
str += date.format(options.meridiemFormat); | ||
} | ||
return str; | ||
str = date.minutes() === 0 && options.implicitMinutes && !options.twentyFourHour ? date.format(options.hourFormat) : date.format("" + options.hourFormat + ":" + options.minuteFormat); | ||
if (!options.groupMeridiems && !options.twentyFourHour) { | ||
if (options.spaceBeforeMeridiem) str += " "; | ||
str += date.format(options.meridiemFormat); | ||
} | ||
return str; | ||
}, | ||
pre: ", ", | ||
slot: 4 | ||
slot: 5 | ||
}); | ||
@@ -138,0 +146,0 @@ } |
{ | ||
"name": "twix", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Twix.js allows you to format date ranges", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/icambron/twix.js", |
@@ -142,3 +142,3 @@ (function() { | ||
describe("ungroup meridiems", function() { | ||
return test("should put meridiems on both sides", { | ||
test("should put meridiems on both sides", { | ||
start: thisYear("5/25", "5:30 AM"), | ||
@@ -151,2 +151,10 @@ end: thisYear("5/25", "7:30 AM"), | ||
}); | ||
return test("even with abbreviated hours", { | ||
start: thisYear("5/25", "7:00 PM"), | ||
end: thisYear("5/25", "9:00 PM"), | ||
options: { | ||
groupMeridiems: false | ||
}, | ||
result: "May 25, 7 PM - 9 PM" | ||
}); | ||
}); | ||
@@ -164,3 +172,3 @@ describe("no meridiem spaces", function() { | ||
}); | ||
return describe("24 hours", function() { | ||
describe("24 hours", function() { | ||
test("shouldn't show meridians", { | ||
@@ -183,2 +191,29 @@ start: thisYear("5/25", "5:30 AM"), | ||
}); | ||
return describe("show day of week", function() { | ||
test("should show day of week", { | ||
start: thisYear("5/25", "5:30 AM"), | ||
end: thisYear("5/28", "7:30 PM"), | ||
options: { | ||
showDayOfWeek: true | ||
}, | ||
result: "Fri May 25, 5:30 AM - Mon May 28, 7:30 PM" | ||
}); | ||
test("collapses show day of week", { | ||
start: thisYear("5/25", "5:30 AM"), | ||
end: thisYear("5/25", "7:30 PM"), | ||
options: { | ||
showDayOfWeek: true | ||
}, | ||
result: "Fri May 25, 5:30 AM - 7:30 PM" | ||
}); | ||
return test("doesn't collapse with one week of separation", { | ||
start: thisYear("5/25"), | ||
end: thisYear("6/1"), | ||
allDay: true, | ||
options: { | ||
showDayOfWeek: true | ||
}, | ||
result: "Fri May 25 - Fri Jun 1" | ||
}); | ||
}); | ||
}); | ||
@@ -185,0 +220,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58933
1035