aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/smart_date.coffee13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee
index 48aa1c2f9..9c8b44207 100644
--- a/app/assets/javascripts/smart_date.coffee
+++ b/app/assets/javascripts/smart_date.coffee
@@ -14,11 +14,16 @@ window.isLeapYear = (year) ->
window.smartCorrectDate = ->
allSelectors = $(@).parent().children('select')
- allVals = allSelectors.map (index, sel) ->
- parseInt($(sel).val())
+
+ yearSelect = allSelectors.filter("[name$='(1i)]']")
+ monthSelect = allSelectors.filter("[name$='(2i)]']")
+ daySelect = allSelectors.filter("[name$='(3i)]']")
+ # We expect [day, month, year], so french
+ allVals = [daySelect, monthSelect, yearSelect].map (sel, index) ->
+ parseInt(sel.val())
+
correctedDay = correctDay allVals
- daySelector = allSelectors.first()
- $(daySelector).val(correctedDay)
+ daySelect.val(correctedDay)
$ ->
$(document).on 'change', '.smart_date select', smartCorrectDate