diff options
| author | Robert | 2017-06-28 16:24:17 +0200 | 
|---|---|---|
| committer | Robert | 2017-06-28 16:24:17 +0200 | 
| commit | 3b0c79da928859988b6da5a8358a0b953c334ca9 (patch) | |
| tree | f3a1007aa074b063aec70750c0a5bb061350cc45 /app | |
| parent | 5d5e806f25c74ed42bf9aba4950e069f2911e002 (diff) | |
| download | chouette-core-3b0c79da928859988b6da5a8358a0b953c334ca9.tar.bz2 | |
Hotfix Fixes: #3906@1h
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/javascripts/smart_date.coffee | 19 | 
1 files changed, 12 insertions, 7 deletions
diff --git a/app/assets/javascripts/smart_date.coffee b/app/assets/javascripts/smart_date.coffee index 8e416de82..afc0c7ddf 100644 --- a/app/assets/javascripts/smart_date.coffee +++ b/app/assets/javascripts/smart_date.coffee @@ -1,16 +1,21 @@ -window.legalDaysPerMonth       = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] +window.legalDaysPerMonth = +  false: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], +  true:  [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] -window.isLeapYear = (year) -> -  (year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0)) +window.legal  window.correctDay = (dateValues) ->    [day, month, year] = dateValues -  return day if legalDaysPerMonth[month-1] >= day -  return 29 if day == 29 && isLeapYear(year) -  legalDaysPerMonth[month-1] +  return day unless day > 0 && month > 0 && year > 0 + +  legallyMaximumDay = legalDaysPerMonth[isLeapYear(year)][month - 1] +  Math.min day, legallyMaximumDay + +window.isLeapYear = (year) -> +  (year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0))  window.smartCorrectDate = -> -  allSelectors = $(@).parent().children('select') # N'a pas un sibbling('select', include_self = true) ? +  allSelectors = $(@).parent().children('select')    allVals      = allSelectors.map (index, sel) ->      parseInt($(sel).val())    correctedDay = correctDay allVals  | 
