aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/date/helper.js
blob: 2f6f51fd95a83586b8711ec54772ba806ead8651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
define( [
	"jquery",
	"globalize",
	"lib/helper",
	"globalize/date"
], function( $, Globalize, helper ) {

return $.extend( helper, {
	getAttributes: function( locale ) {
		var globalize = new Globalize( locale ),
			weekdayShortFormatter = globalize.dateFormatter( { raw: "EEEEEE" } ),
			weekdayNarrowFormatter = globalize.dateFormatter( { raw: "EEEEE" } ),
			firstDayRaw = globalize.dateFormatter( { raw: "c" } )( new Date( 1970, 0, 3 ) );

		return {
			firstDay: ( 7 - globalize.parseNumber( firstDayRaw ) ),
			formatWeekdayShort: function( date ) {

				// Return the short weekday if its length is < 3. Otherwise, its narrow form.
				var shortWeekday = weekdayShortFormatter( date );

				return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday;
			},
			formatWeekdayFull: globalize.dateFormatter( { raw: "EEEE" } ),
			formatMonth: globalize.dateFormatter( { raw: "MMMM" } ),
			formatWeekOfYear: globalize.dateFormatter( { raw: "w" } )
		};
	}
} );

} );