0adbda8034
This patch is to display corrextly the new dmydot date format e.g. after using the datepicker or in messages for the user, in following files: - koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc - koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc - koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc - koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt - koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc - tools/holidays.pl To test: - Apply patch - Make sure that you have syspref dateformat set to dmydot - Use datepicker in OPAC (modify birth date), verify that after choosing a date, it is displayed correctly in the datepicker - Use datepicker at several places in OPAC, verify that after choosing a date the date displays properly in datepicker and that the dater format is properly indicated (e.g. near birth date or near "Specify due date"). - Verify that datepicker works well with hoiday editing and that "From date:" displays properly Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
109 lines
4.2 KiB
SourcePawn
109 lines
4.2 KiB
SourcePawn
[% USE Koha %]
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
|
|
var debug = "[% debug %]";
|
|
var dformat = "[% dateformat %]";
|
|
var sentmsg = 0;
|
|
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
|
|
|
|
function Date_from_syspref(dstring) {
|
|
var dateX = dstring.split(/[-/.]/);
|
|
if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
|
|
if (dformat === "iso") {
|
|
return new Date(dateX[0], (dateX[1] - 1), dateX[2]); // YYYY-MM-DD to (YYYY,m(0-11),d)
|
|
} else if (dformat === "us") {
|
|
return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d)
|
|
} else if (dformat === "metric") {
|
|
return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY to (YYYY,m(0-11),d)
|
|
} else if (dformat === "dmydot") {
|
|
return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD.MM.YYYY to (YYYY,m(0-11),d)
|
|
} else {
|
|
if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
function DateTime_from_syspref(date_time) {
|
|
var parts = date_time.split(" ");
|
|
var date = parts[0];
|
|
var time = parts[1];
|
|
parts = time.split(":");
|
|
var hour = parts[0];
|
|
var minute = parts[1];
|
|
|
|
if ( hour < 0 || hour > 23 ) {
|
|
return 0;
|
|
}
|
|
if ( minute < 0 || minute > 59 ) {
|
|
return 0;
|
|
}
|
|
|
|
var datetime = Date_from_syspref( date );
|
|
|
|
if ( isNaN( datetime.getTime() ) ) {
|
|
return 0;
|
|
}
|
|
|
|
datetime.setHours( hour );
|
|
datetime.setMinutes( minute );
|
|
|
|
return datetime;
|
|
}
|
|
|
|
|
|
/* Instead of including multiple localization files as you would normally see with
|
|
jQueryUI we expose the localization strings in the default configuration */
|
|
jQuery(function($){
|
|
$.datepicker.regional[''] = {
|
|
closeText: _("Done"),
|
|
prevText: _("Prev"),
|
|
nextText: _("Next"),
|
|
currentText: _("Today"),
|
|
monthNames: [_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),
|
|
_("July"),_("August"),_("September"),_("October"),_("November"),_("December")],
|
|
monthNamesShort: [_("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"),
|
|
_("Jul"), _("Aug"), _("Sep"), _("Oct"), _("Nov"), _("Dec")],
|
|
dayNames: [_("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")],
|
|
dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
|
|
dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
|
|
weekHeader: _("Wk"),
|
|
dateFormat: "[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSIF ( dateformat == "dmydot" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]",
|
|
firstDay: [% Koha.Preference('CalendarFirstDayOfWeek') %],
|
|
isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
|
|
showMonthAfterYear: false,
|
|
yearSuffix: ''};
|
|
$.datepicker.setDefaults($.datepicker.regional['']);
|
|
});
|
|
|
|
$(document).ready(function(){
|
|
|
|
$.datepicker.setDefaults({
|
|
showOn: "both",
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
buttonImage: '[% interface %]/[% theme %]/img/famfamfam/silk/calendar.png',
|
|
buttonImageOnly: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true
|
|
});
|
|
|
|
$( ".datepicker" ).datepicker();
|
|
// http://jqueryui.com/demos/datepicker/#date-range
|
|
var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
|
|
changeMonth: true,
|
|
numberOfMonths: 1,
|
|
onSelect: function( selectedDate ) {
|
|
var option = this.id == "from" ? "minDate" : "maxDate",
|
|
instance = $( this ).data( "datepicker" );
|
|
date = $.datepicker.parseDate(
|
|
instance.settings.dateFormat ||
|
|
$.datepicker._defaults.dateFormat,
|
|
selectedDate, instance.settings );
|
|
dates.not( this ).datepicker( "option", option, date );
|
|
}
|
|
});
|
|
});
|
|
//]]>
|
|
</script>
|