Explorar el Código

add week to similarUnitMap (also fixes issue 2371)

René Springer hace 10 años
padre
commit
f325ca5de4
Se han modificado 2 ficheros con 7 adiciones y 1 borrados
  1. 2 1
      src/date-formatting.js
  2. 5 0
      tests/automated/formatRange.js

+ 2 - 1
src/date-formatting.js

@@ -150,6 +150,8 @@ function formatRangeWithChunks(date1, date2, chunks, separator, isRTL) {
 var similarUnitMap = {
 var similarUnitMap = {
 	Y: 'year',
 	Y: 'year',
 	M: 'month',
 	M: 'month',
+	w: 'week', // week of year
+	W: 'week', // week of year (ISO)
 	D: 'day', // day of month
 	D: 'day', // day of month
 	d: 'day', // day of week
 	d: 'day', // day of week
 	// prevents a separator between anything time-related...
 	// prevents a separator between anything time-related...
@@ -162,7 +164,6 @@ var similarUnitMap = {
 	m: 'second', // minute
 	m: 'second', // minute
 	s: 'second' // second
 	s: 'second' // second
 };
 };
-// TODO: week maybe?
 
 
 
 
 // Given a formatting chunk, and given that both dates are similar in the regard the
 // Given a formatting chunk, and given that both dates are similar in the regard the

+ 5 - 0
tests/automated/formatRange.js

@@ -41,6 +41,11 @@ describe('formatRange', function() {
 		expect(s).toEqual('January 1st 2014');
 		expect(s).toEqual('January 1st 2014');
 	});
 	});
 
 
+	it('outputs the single week number when dates have the same week and format string is week', function() {
+		var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-01', 'W');
+		expect(s).toEqual('1');
+	});
+
 	it('uses a custom separator', function() {
 	it('uses a custom separator', function() {
 		var s = $.fullCalendar.formatRange(
 		var s = $.fullCalendar.formatRange(
 			'2014-01-01T06:00:00',
 			'2014-01-01T06:00:00',