Skip to content
This repository was archived by the owner on Dec 15, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/js/bootstrap-datetimepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
this.language = options.language in dates ? options.language : 'en'
this.pickDate = options.pickDate;
this.pickTime = options.pickTime;
this.hourStep = options.hourStep;
this.minuteStep = options.minuteStep;
this.secondStep = options.secondStep;
this.isInput = this.$element.is('input');
this.component = false;
if (this.$element.find('.input-append') || this.$element.find('.input-prepend'))
Expand Down Expand Up @@ -639,27 +642,27 @@

actions: {
incrementHours: function(e) {
this._date.setUTCHours(this._date.getUTCHours() + 1);
this._date.setUTCHours(this._date.getUTCHours() + this.hourStep);
},

incrementMinutes: function(e) {
this._date.setUTCMinutes(this._date.getUTCMinutes() + 1);
this._date.setUTCMinutes(this._date.getUTCMinutes() + this.minuteStep);
},

incrementSeconds: function(e) {
this._date.setUTCSeconds(this._date.getUTCSeconds() + 1);
this._date.setUTCSeconds(this._date.getUTCSeconds() + this.secondStep);
},

decrementHours: function(e) {
this._date.setUTCHours(this._date.getUTCHours() - 1);
this._date.setUTCHours(this._date.getUTCHours() - this.hourStep);
},

decrementMinutes: function(e) {
this._date.setUTCMinutes(this._date.getUTCMinutes() - 1);
this._date.setUTCMinutes(this._date.getUTCMinutes() - this.minuteStep);
},

decrementSeconds: function(e) {
this._date.setUTCSeconds(this._date.getUTCSeconds() - 1);
this._date.setUTCSeconds(this._date.getUTCSeconds() - this.secondStep);
},

togglePeriod: function(e) {
Expand Down Expand Up @@ -1097,7 +1100,10 @@
pickSeconds: true,
startDate: -Infinity,
endDate: Infinity,
collapse: true
collapse: true,
hourStep: 1,
minuteStep: 1,
secondStep: 1
};
$.fn.datetimepicker.Constructor = DateTimePicker;
var dpgId = 0;
Expand Down
18 changes: 11 additions & 7 deletions test/specs.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
describe 'datetimepicker', ->

beforeEach setupDateTimePicker()
beforeEach setupDateTimePicker({
hourStep: 2,
minuteStep: 5,
secondStep: 15
})

afterEach teardownDateTimePicker()

Expand Down Expand Up @@ -118,29 +122,29 @@ describe 'datetimepicker', ->
.to.be.true
done()

it 'increments/decrements hour', ->
it 'adds/subtracts the hours step', ->
@addon.click()
@widget.find('.picker-switch a').click()
@timeWidget.find('[data-action=incrementHours]').click()
@dateShouldEqual 1905, 4, 1, 22, 52, 14
@dateShouldEqual 1905, 4, 1, 23, 52, 14
@timeWidget.find('[data-action=decrementHours]').click()
@dateShouldEqual 1905, 4, 1, 21, 52, 14

it 'increments/decrements minutes', ->
it 'adds/subtracts the minutes step', ->
@addon.click()
@widget.find('.picker-switch a').click()
@timeWidget.find('[data-action=incrementMinutes]').click()
# 15 minutes step is the default
@dateShouldEqual 1905, 4, 1, 21, 53, 14
@dateShouldEqual 1905, 4, 1, 21, 57, 14
@timeWidget.find('[data-action=decrementMinutes]').click()
@dateShouldEqual 1905, 4, 1, 21, 52, 14

it 'increments/decrements minutes', ->
it 'adds/subtracts the seconds step', ->
@addon.click()
@widget.find('.picker-switch a').click()
@timeWidget.find('[data-action=incrementSeconds]').click()
# 30 seconds step is the default
@dateShouldEqual 1905, 4, 1, 21, 52, 15
@dateShouldEqual 1905, 4, 1, 21, 52, 29
@timeWidget.find('[data-action=decrementSeconds]').click()
@dateShouldEqual 1905, 4, 1, 21, 52, 14

Expand Down