jQuery datepicker显示佛教日期 [英] jQuery datepicker displaying a Buddhist date

查看:96
本文介绍了jQuery datepicker显示佛教日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何jQuery datepicker插件显示为佛教日期?

Is there any jQuery datepicker plugin to display as Buddhist date?

目前我使用 jQuery UI datepicker来显示它,但它实际上并不是我想要的。以下是代码:

Currently I use the jQuery UI datepicker to display it, but it's not actually I want. Here is the code:

$(document).ready( function() {
    $("#datepicker").datepicker( {
        appendText: ' yyyy-mm-dd',
        autoSize: true,
        buttonImage: 'images/calendar.gif',
        buttonImageOnly: true,
        changeMonth: true,
        changeYear: true,
        dateFormat: 'yy-mm-dd',
        showOtherMonths: true,
        selectOtherMonths: true,
        showOn: 'both',
        onSelect: function(dateText, inst) {
            year = dateText.substring(0, 4);
            month = dateText.substring(5, 7);
            day = dateText.substring(8);
            _year = parseInt(year) + 543 + '';
            $(this).val(_year + '-' + month + '-' + day);
        },
        beforeShow: function(input, inst) {
            year = input.value.substring(0, 4);
            month = input.value.substring(5, 7);
            day = input.value.substring(8);
            _year = parseInt(year) - 543 + '';
            $(this).datepicker("setDate", new Date(_year, month - 1, day, 0, 0, 0, 0));
        }
    });
});

我想要的是当 #datepicker 有没有值,日历弹出显示当前日期+ 543年。当 #datepicker 有值时,弹出的日历会在 #datepicker 值中显示日期。

What I want is when #datepicker has no value, the calendar pop up is displaying the current date + 543 years. When #datepicker has a value, the calendar pop up is displaying the date in the #datepicker value.

问题是所选年份是闰年,例如,2008-02-29 AD有效但我们无法显示2551-02-29(佛教日期)弹出窗口(即同一日期)。

The problem is when the selected year is a leap year, for example, 2008-02-29 AD is valid but we can't display 2551-02-29 (Buddhist date) (which is the same date) on that pop up.

更新2010-07-30

根据 在datepicker模块中添加对泰语年份格式的支持 Datepicker:支持非Gregorian日历 似乎他们计划为非Gregorian日历创建支持。

According to Add support for Thai year format in datepicker module and Datepicker: Support non-Gregorian calendars it seems they plan to create support for non-Gregorian calendars.

目前我尝试使用插件 Keith Wood 的htmlrel =nofollow noreferrer> jQuery Calendars 。

Currently I try to use the plugin jQuery Calendars by Keith Wood.

推荐答案

你可以在这里找到我修改过的jQuery DatePicker版本:

You can find my modified version of jQuery DatePicker here:

http://www.anassirk.com/articles/1

博客是泰语,所以我会简要说明如下:

The blog is in Thai so I'll briefly explain it below:

在此处下载插件:
http://www.anassirk.com/files/DatePicker.zip

该用法非常类似于标准的jQuery DatePicker,带有一个额外的布尔选项命名为isBuddhist,您可以将其设置为true以呈现佛教日历。

The usage is quite similar to the standard jQuery DatePicker with one extra boolean option named "isBuddhist" which you can set it to true to render the Buddhist calendar.

$("#datepicker-th").datepicker({ dateFormat: 'dd/mm/yy', isBuddhist: true, defaultDate: toDay }); 

重要:在佛教模式中你必须设置defaultDate选项到dateFormat选项中指定格式的日期字符串。比如'19 / 3/2554'代表'dd / mm / yy'

important: in Buddhist mode you have to set the "defaultDate" option to a date string of the format specified in the "dateFormat" option. Like '19/3/2554' for 'dd/mm/yy'

干杯!

这篇关于jQuery datepicker显示佛教日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆