Use Popup Calendar in BE format (พ.ศ.)

Tips submitted by PHPMaker users
Post Reply
analizer

Use Popup Calendar in BE format (พ.ศ.)

Post by analizer »

siam_hacker(at)hotmail.com [Kenny G.--Thailand]
1.if you want to use calendar with year in BE format (พ.ศ.)
2.open "calendar.js" file in "calendar" folder
2.1 find this code
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
// member variables
this.activeDiv = null;
2.2 change it
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
// Special Variable
this.YearStyle = false; // set year format as you want (false = AD(ค.ศ.),true = BE(พ.ศ.))
// member variables
this.activeDiv = null;
2.3 find this code
if (Y >= cal.minYear && Y <= cal.maxYear) {
yr.innerHTML = Y;
yr.year = Y;
2.4 change it
if (Y >= cal.minYear && Y <= cal.maxYear) {
//------------------------------------------------------------------------------------------------------//
if (!calendar.YearStyle) yr.innerHTML = Y; // Show year list in AD format, แสดงรายการปีในแบบ ค.ศ.
if (calendar.YearStyle) yr.innerHTML = (Y+543); // Show year list in BE format, แสดงรายการปีในแบบ พ.ศ.
//------------------------------------------------------------------------------------------------------//
yr.year = Y;
2.5 find this code
this.title.innerHTML = Calendar.MN[month] + ", " + year;
2.6 then change it
//------------------------------------------------------------------------------------------------------//
if (!this.YearStyle) this.title.innerHTML = Calendar.
MN[month] + ", " + year; // แสดงหัวปฏิทินในแบบ ค.ศ.
if (this.YearStyle) this.title.innerHTML = Calendar._MN[month] + ", " + (year+543); // แสดงหัวปฏิทินในแบบ พ.ศ.
//------------------------------------------------------------------------------------------------------//
2.7 find this code
var y = this.getFullYear();
2.8 in "Date.prototype.print = function (str,a) { " function, then change it
//-------------------------------------------------------------------------------------------------------------------//
if (!calendar.YearStyle) var y = this.getFullYear(); // send year in AD format to InputField,ส่งวันที่ที่เลือกไปยังช่องรับวันที่
if (calendar.YearStyle) var y = this.getFullYear()+543; // send year in BE format to InputField
//-------------------------------------------------------------------------------------------------------------------//
2.9 save it

  1. you can include it to template file and extension

analizer

Post by analizer »

I forgot it :)

2.2.1 find this code
this.dateStr = dateStr;
2.2.2 then change it
//---------------------------------------------------------------------------------------//
if (this.YearStyle) dateStr.setFullYear(dateStr.getFullYear()-543); // if year format is BE format, you must convert BE->AD
//---------------------------------------------------------------------------------------//
this.dateStr = dateStr;


siriok
User
Posts: 107

Post by siriok »

ใช้ v10.0.1 เปลี่ยนโค๊ดแล้วไม่ได้ครับ..
can't to change AD to BE
รบกวน ช่วยแก้ให้หน่อยครับ..
please change the new code?
thank u
ขอบคุณครับ


Post Reply