-
-
Save Krule/736937 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on http://snipt.net/boriscy/datetime-jquery-formtastic/ | |
$.tools.dateinput.localize("ja", { | |
months: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月', | |
shortMonths: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月', | |
days: '日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日', | |
shortDays: '日,月,火,水,木,金,土' | |
}); | |
$.tools.dateinput.conf.format = 'yyyy-mm-dd'; | |
$(document).ready(function() { | |
$.tools.dateinput.conf.lang = $('html').attr('lang'); | |
$('div.date, div.datetime').each(function(i, el) { | |
var sels = $(el).find("select:lt(3)"); | |
var d = new Date(sels[0].value, parseInt(sels[1].value) - 1, sels[2].value); | |
var dateinput = $("<input type='date'>").dateinput({ value: d} ); | |
// Without this, the field is initially blank | |
dateinput.val(dateinput.data().dateinput.getValue($.tools.dateinput.conf.format)); | |
dateinput.change(function(event, date) { | |
$(sels[0]).val(date.getFullYear()); | |
$(sels[1]).val(date.getMonth() + 1); | |
$(sels[2]).val(date.getDate()); | |
}); | |
$(sels[0]).before(dateinput); | |
$(sels).hide(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment