Skip to content

Commit

Permalink
Add ISO week numbers option
Browse files Browse the repository at this point in the history
  • Loading branch information
dangrossman committed Feb 22, 2016
1 parent 6118677 commit 9776627
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
10 changes: 8 additions & 2 deletions daterangepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
this.singleDatePicker = false;
this.showDropdowns = false;
this.showWeekNumbers = false;
this.showISOWeekNumbers = false;
this.timePicker = false;
this.timePicker24Hour = false;
this.timePickerIncrement = 1;
Expand Down Expand Up @@ -217,6 +218,9 @@
if (typeof options.showWeekNumbers === 'boolean')
this.showWeekNumbers = options.showWeekNumbers;

if (typeof options.showISOWeekNumbers === 'boolean')
this.showISOWeekNumbers = options.showISOWeekNumbers;

if (typeof options.buttonClasses === 'string')
this.buttonClasses = options.buttonClasses;

Expand Down Expand Up @@ -672,7 +676,7 @@
html += '<tr>';

// add empty cell for week number
if (this.showWeekNumbers)
if (this.showWeekNumbers || this.showISOWeekNumbers)
html += '<th></th>';

if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
Expand Down Expand Up @@ -727,7 +731,7 @@
html += '<tr>';

// add week number label
if (this.showWeekNumbers)
if (this.showWeekNumbers || this.showISOWeekNumbers)
html += '<th class="week">' + this.locale.weekLabel + '</th>';

$.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
Expand All @@ -753,6 +757,8 @@
// add week number
if (this.showWeekNumbers)
html += '<td class="week">' + calendar[row][0].week() + '</td>';
else if (this.showISOWeekNumbers)
html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';

for (var col = 0; col < 7; col++) {

Expand Down
9 changes: 9 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ <h1 style="margin: 0 0 20px 0">Configuration Builder</h1>
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="showISOWeekNumbers"> showISOWeekNumbers
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="timePicker"> timePicker
Expand Down Expand Up @@ -248,6 +254,9 @@ <h4>Configuration</h4>
if ($('#showWeekNumbers').is(':checked'))
options.showWeekNumbers = true;

if ($('#showISOWeekNumbers').is(':checked'))
options.showISOWeekNumbers = true;

if ($('#timePicker').is(':checked'))
options.timePicker = true;

Expand Down
11 changes: 10 additions & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ <h2>Configuration Generator</h2>
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="showISOWeekNumbers"> showISOWeekNumbers
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="timePicker"> timePicker
Expand Down Expand Up @@ -594,7 +600,10 @@ <h2>Options</h2>
<code>showDropdowns</code>: (boolean) Show year and month select boxes above calendars to jump to a specific month and year
</li>
<li>
<code>showWeekNumbers</code>: (boolean) Show week numbers at the start of each week on the calendars
<code>showWeekNumbers</code>: (boolean) Show localized week numbers at the start of each week on the calendars
</li>
<li>
<code>showWeekNumbers</code>: (boolean) Show ISO week numbers at the start of each week on the calendars
</li>
<li>
<code>timePicker</code>: (boolean) Allow selection of dates with times, not just dates
Expand Down
3 changes: 3 additions & 0 deletions website/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ $(document).ready(function() {
if ($('#showWeekNumbers').is(':checked'))
options.showWeekNumbers = true;

if ($('#showISOWeekNumbers').is(':checked'))
options.showISOWeekNumbers = true;

if ($('#timePicker').is(':checked'))
options.timePicker = true;

Expand Down

0 comments on commit 9776627

Please sign in to comment.