Git Product home page Git Product logo

md.bootstrappersiandatetimepicker's Introduction

MD.BootstrapPersianDateTimePicker

Bootstrap 5+ Persian And Gregorian Date Time Picker

Major changes:

  1. Using Bootstrap 5
  2. jQuery Removed
  3. Rewrite all codes, better performance

MD.BootstrapPersianDateTimePicker Demo

MD.BootstrapPersianDateTimePicker MD.BootstrapPersianDateTimePicker

NOTE:

Bootstrap 3 version https://github.com/Mds92/MD.BootstrapPersianDateTimePicker/tree/master-bs3
Bootstrap 4 version https://github.com/Mds92/MD.BootstrapPersianDateTimePicker/tree/master-bs4

Installing:

First you have to install Bootstrap 5 and link it to your html file.

Then you can install latest version of the library via npm:

npm install md.bootstrappersiandatetimepicker@latest

Now add these files to you html:

<link href="/dist/mds.bs.datetimepicker.style.css" rel="stylesheet"/>
<script src="/dist/mds.bs.datetimepicker.js"></script>
NOTE:

This library css file must be after bootstrap css file

I suggest to add scripts at the end of body tag and after bootstrap js file.

How to use:

const dtp1Instance = new mds.MdsPersianDateTimePicker(document.getElementById('dtp1'), {
  targetTextSelector: '[data-name="dtp1-text"]',
  targetDateSelector: '[data-name="dtp1-date"]',
});

Options:

Default values are into [ ]

Name Values Description Sample
placement top, right, [bottom], left Position of date time picker
trigger [click], mouse down, focus, ... Event to show date time picker
enableTimePicker [false], true Time picker visibility
targetTextSelector String CSS selector to show selected date as format property into it '#TextBoxId'
targetDateSelector String CSS selector to save selected date into it '#InputHiddenId'
toDate [false], true When you want to set date picker as toDate to enable date range selecting
fromDate [false], true When you want to set date picker as fromDate to enable date range selecting
groupId String When you want to use toDate, fromDate you have to enter a group id to specify date time pickers 'dateRangeSelector1'
disabled [false], true Disable date time picker
textFormat String format of selected date to show into targetTextSelector 'yyyy/MM/dd HH:mm:ss'
dateFormat String format of selected date to save into targetDateSelector 'yyyy/MM/dd HH:mm:ss'
isGregorian [false], true Is calendar Gregorian
inLine [false], true Is date time picker in line
modalMode [false], true Open in modal mode, suitable for smart phones
selectedDate [undefined], Date Selected date as JavaScript Date object new Date('2018/9/30')
selectedDateToShow [new Date()], Date Selected date to start calendar from it as JavaScript Date object new Date('2018/9/30')
selectedRangeDate Array: Date[] Selected range date as JavaScript Date object [new Date('2020/8/5'), new Date('2020/8/15')]
yearOffset Number Number of years to select in year selector 30
holidays Array: Date[] Array of holidays to show in date time picker as holiday [new Date(), new Date(2017, 3, 2)]
disabledDates Array: Date[] Array of disabled dates to prevent user to select them [new Date(2017, 1, 1), new Date(2017, 1, 2)]
specialDates Array: Date[] Array of dates to mark some dates as special [new Date(2017, 2, 1), new Date(2017, 3, 2)]
disabledDays Array: number[] Array of disabled week days to prevent user to select them Disable all "Thursday", "Friday" in persian [ 5, 6 ]
disableBeforeToday [false], true Disable days before today
disableAfterToday [false], true Disable days after today
disableBeforeDate Date Disable days before this Date new Date(2018, 11, 12)
disableAfterDate Date Disable days after this Date new Date(2018, 12, 11)
rangeSelector [false], true Enables rangeSelector feature on date time picker
monthsToShow Numeric array with 2 items, [0 ,0] To show, number of month before and after selected date in date time picker, first item is for before month, second item is for after month [1, 1]
persianNumber [false], true Convert numbers to persian characters
calendarViewOnChange(date) function Event fires on date picker's view change
onDayClick(event) function Event fires on day cell click

String format:

Format English Description Persian Description
yyyy Year, 4 digits سال چهار رقمی
yy Year, 2 digits سال دو رقمی
MMMM Month name نام ماه
MM Month, 2 digits عدد دو رقمی ماه
M Month, 1 digit عدد تک رقمی ماه
dddd Week day name نام روز هفته
dd Month's day, 2 digits عدد دو رقمی روز
d Month's day, 1 digit عدد تک رقمی روز
HH Hour, 2 digits - 0 - 24 عدد دو رقمی ساعت با فرمت 0 تا 24
H Hour, 1 digit - 0 - 24 عدد تک رقمی ساعت با فرمت 0 تا 24
hh Hour, 2 digits - 0 - 12 عدد دو رقمی ساعت با فرمت 0 تا 12
h Hour, 1 digit - 0 - 12 عدد تک رقمی ساعت با فرمت 0 تا 12
mm Minute, 2 digits عدد دو رقمی دقیقه
m Minute, 1 digit عدد تک رقمی دقیقه
ss Second, 2 digits ثانیه دو رقمی
s Second, 1 digit ثانیه تک رقمی
tt AM / PM ب.ظ یا ق.ظ
t A / P حرف اول از ب.ظ یا ق.ظ

Functions:

Name Return Value Description Sample
show void show date picker dtp1Instance.show()
hide void hide date picker dtp1Instance.hide()
toggle void show or hide date picker dtp1Instance.toggle()
enable void enable date picker dtp1Instance.enable()
disable void disable date picker dtp1Instance.disable()
updatePosition void update position of date picker dtp1Instance.updatePosition()
updateSelectedDateText void update targetTextSelector text dtp1Instance.updateSelectedDateText()
dispose void dispose date picker dtp1Instance.dispose()
getBsPopoverInstance bootstrap.Popover return instance of bootstrap popover const bsPopover = dtp1Instance.getBsPopoverInstance()
getBsModalInstance bootstrap.Modal return instance of bootstrap modal const bsModal = dtp1Instance.getBsModalInstance()
updateOption void update one option of date picker dtp1Instance.updateOption('isGregorian', false)
updateOptions void update one option of date picker dtp1Instance.updateOptions({ isGregorian: false, inLine: false, ... })
getInstance MdsPersianDateTimePicker static method, get instance of MdsDatePicker by an element obj const jalaliObj = mds.MdsPersianDateTimePicker.getInstance(document.getELementById('IdOfElement'));
getText string Get selected date text const txt = dtp1Instance.getText()
getDate Date Get selected date const dateObj = dtp1Instance.getDate()
getDateRange [fromDate, toDate]: Date[] Get selected date range dtp1Instance.getDateRange();
setDate void Set selected datetime with Date object argument dtp1Instance.setDate(new Date('2021/09/22'));
setDatePersian void Set selected datetime with Date object argument dtp1Instance.setDatePersian(1400, 06, 31);
setDateRange void Set selected datetime range with Date object argument dtp1Instance.setDateRange(new Date('2021/09/04'), new Date('2021/09/22'));
clearDate void clear selected date dtp1Instance.clearDate();
convertDateToString string utility & static method, convert date object to string const dateStr = mds.MdsPersianDateTimePicker.convertDateToString(date: new Date(), isGregorian: false, format: 'yyyy/MM/dd');
convertDateToJalali json utility & static method, convert date object to Jalali const jalaliObj = mds.MdsPersianDateTimePicker.convertDateToJalali(new Date());

Events:

MD.BootstrapPersianDateTimePicker uses Bootstrap's popover and modals. so you can use popover or modal events.

https://getbootstrap.com/docs/5.1/components/popovers/#events https://getbootstrap.com/docs/5.1/components/modal/#events


Backend:

If you are using .net in your backend I suggest you https://github.com/Mds92/MD.PersianDateTime to handle PersianDateTime as easy as DateTime.

md.bootstrappersiandatetimepicker's People

Contributors

mds92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

md.bootstrappersiandatetimepicker's Issues

قابلیت ست کردن دوباره و آنست کردن و تغییر گزینه ها Set and Unset

با سلام دوباره
این پلاگین اگه بشه دوباره با فراخانی جاوا اسکریپت دوباره ست بشه و تغییر حالت بده خیلی کمک میکنه
و از همه مهمتر باید راحی وجود داشته باشه که پلاگین ست شده روی المنتی رو بشه آنست کرد و دیگه کار نکنه. این قابلیت در قسمت های خاصی که ما میخوایم المنتی رو غیب یا غیر فعال کنیم خیلی به درد میخوره.

مرسی از توجه شما

نحوه بکارگیری در mvc form

سلام
کنترل خوبی طراحی کردید ضمن تشکر از شما
زمانیکه درون فرم بکار برده شود چنانچه تکست باکس تاریخ فوکوس بگیرد
تقویم نشون داده میشه وقتی یکی از روزهای تاریخ انتخاب میشه تکست باکس تاریخ به روز نمیشه
اگر راهنمایی کنید ممنون میشم

@using (Html.BeginForm())
{
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)
            <div class="form-horizontal">
                <div class="form-group">
                    @Html.LabelFor(m => m.StartDate, new { @class = "control-label", @for = "fromdate" })
                    <div class="input-group">
                        <span class="input-group-addon" data-mddatetimepicker="true" data-trigger="click" data-targetselector="#fromdate" data-fromdate="true" data-enabletimepicker="false" data-placement="bottom">
                            <span class="fa fa-calendar"></span>
                        </span>
                        @Html.TextBoxFor(m => m.StartDate, new { @class = "form-control", id = "fromdate", placeholder = "از تاریخ", data_groupId = "group1", data_mddatetimepicker = "true", data_trigger = "focus", data_targetselector = "#fromdate", data_fromdate = "true", data_enabletimepicker = "false", data_placement = "bottom" })
                    </div>
                    @Html.ValidationMessageFor(m => m.StartDate, "", new { @class = "text-danger" })
                </div>
}

مشکل در placement

سلام ، ممنون از کد عالی شما و تشکر از تلاشتون، من از تقویم شما در برنامه
asp.nwt mvc
نسخه 5 استفاده کردم و نسخه
bootstrapt و jquery هم به اخرین نسخه ارتقا دادم .
مشکلی در استفاده از کد شما دارم و این که در صورتی که یکی یا بیشتر تقویم در صفحه باشه همیشه تقویم در گوشه سمت راست صفحه باز میشه
حتی اگر چند تا تقویم باشه منو تقویم بعد از کلیک در جای مناسب نشون داده نمیشه
چند عکس از این موضوع ضمیمه کردم .
باتشکر از توجه شما!
snap9
snap10
snap11

داشتن قابلیت برگرداندن تاریخ اصلی در زمان صدا زدن فرستادن فرم

با سلام و تشکر
خیلی خوب میشد اگه یه متدی وجود داشت که تاریخ انتخاب شده در حال حاظر به صورت تاریخ جاوا اسکریپت یا همون
DateTime
برگردانده میشد اینطوری دیگه نیازی به پارس کردن هم نبود
و حتی بعد میشه در زمان صدا زدن
val
مثل کامپوننت
InputMask
زمان اصلی رو برگردوند اینطوری حتی در زمان فرستادن فرم و سریالایز کردنش هم بدن نیاز به هیچ عملیاتی به تاریخ صحیح تبدیل شده و به سمت سرور میرفت و دیگه نیازی نبود داخل سرور رشته گرفته بشه و دوباره پارس بشه.

مرسی از این کار خیلی خوب 👍

Error

Hello,
I copy all of content demo 2 in my page and add js and css , but i have error when click or select date.
Uncaught TypeError: Cannot set property 'Day' of undefined
at updateDateTimePickerHtml (jquery.Bootstrap-PersianDateTimePicker.js:1374)
at HTMLTableCellElement. (jquery.Bootstrap-PersianDateTimePicker.js:1411)
at HTMLDocument.dispatch (jquery-3.1.0.min.js:3)
at HTMLDocument.q.handle (jquery-3.1.0.min.js:3)

مشکل جانمایی در زمان استفاده از Bootstrap-rtl

با عرض سلام و خسته نباشید بابت ارائه این ابزار مفید

زمانیکه از Bootstrap-rtl جهت راست چین کردن صفحه استفاده میکنم، DatePicker در جای مناسب (با توجه به المان مربوطه) قرار نمیگیره.
از این نسخه استفاده میکنم:
https://www.nuget.org/packages/bootstrap-rtl/3.3.6

اگر راهنمایی بفرمایید ممنون میشم

npm

Please upload it to npm

قرار دادن اعداد انگلیسی به جای فارسی

سلام خسته نباشید
می خواستم وقتی که ما تاریخ رو انتخاب میکنیم در تکست باکس به اعداد را فاررسی نمایش میدهد
من می خواهم اعدادی که در تکست باکس قرار گرفتن به صورت لاتین باشند
میشه راهنمایی بفرمایید ؟

قرار دادن تاریخ انتخابی در value

با سلام اول تشکر بابت زحمتتون
یک مشکل هست و اون این هست که چطور میتونم تاریخ انتخابی به این فرمت 1395/05/23 به خاصیت value انتخابی قرار بدم روی input box و از اونجا در برنامه mvc خودم ارسال کنم به اکشن متد ؟ ممنونم

Bootstrap v4

نسخه سازگار با Bootstrap v4 کی میاد؟

خروجی شمسی برای هر دو تقویم نمایش داده شده شمسی و میلادی

با سلام به شما و تشکر بابت کار خوبتون
من از کامپوننت شما در برنامه ام جهت دریافت تاریخ بصورت رشته شمسی و تغییر اون در سمت سرور به کمک کامپوننت دیگر شما و ذخیره در بانک بصورت نوع تاریخ استفاده میکنم.

مشکلی که وجود داره اینه که کاربر گاهی اوقات نیاز دار تاریخ را در انتخابگر تاریخ بصورت میلادی انتخاب نماید اما رشته نمایش داده شده در ادیتور بصورت شمسی باشد.

در صورت true کردن IsGregorian خروجی تقویم در ادیتور بصورت میلادی خواهد بود نه شمسی و علاوه بر اینکه نیاز کاربر برآورده نمیشود، در سمت سرور هم برای تبدیل با مشکل روبرو خواهم شد.

آیا امکانش هست تقویم هم بصورت میلادی و هم شمسی صرفاً خروجی رشته شمسی داشته باشه؟

ممنون

probllem in gregorian range date time (demo3)

hi
thanks for your nice project.
in the third demo and gregorian range date , after select "start date" , when some times changed "end date" value and turn back to "start date" , its hanging ... please fixed it.
sorry for my bad English
big thanks.

این مشکل در دموی سوم ، و وقتی در تاریخ میلادی "از تاریخ" رو انتخاب می کنید و چند بار مقدار "تا تاریخ" رو تغییر میدهید ، هنگ میکنه
با تشکر

disable بودن کنترلر

سلام دوست عزیز
میشه لطفا مورد من رو بررسی کنین که مشکل از کجاست
اسکریپت های مورد نیاز و همچنین سی اس اس هارو ادد کردم
وقتی پیجم بالا میاد ، کنترلر تاریخ دیزیبلد هست. روش کلیک میکنم چیزی باز نمیشه
اتچ کردم عکس رو.

. موقع نمایش کنترلر بجای اینکه اون انتخاب کننده سمت چپ نشون داده بشه ، سمت راست نشون داده میشه.
من از مترونیک استفاده کردم .

امیدوارم بتونین کمکم کنید.

untitled11

data-fromdate,data-todate

woould you give an example of data-fromdate,data-todate
i cant set them .

how can i limit data-todate to current date .

add switch between Jalali and Gregorian

Hi
thanks for your great project, my bro
please add a button to switch between Jalali to Gregorian and vice versa.
if this feature is, please add sample to show this feature.

very thanks for your work

hello dear @Mds92 i use your date picker in my projects

من چطوری میتونم به جای / از خط تیره - بین روز و ماه و سال استفاده کنم

thank you very much

مشکل با کنترل سمت سرور

سلام
وقتی تگ input رو runat server قرار میدم باعث میشه که دیگه مقدار بهش نسبت داده نشه
میتونین راهنمایی کنین؟

تغییر فرمت

سلام
با تشکر از شما
من این دیت پیکر رو استفاده کردم ، فقط تنها مشکلی که داره اینه که وقتی فرمت نمایش تاریخ رو عوض می کنم هیچ تغییری نمی کنه
ممنون میشم راهنمایی کنید

نمایش فقط ماه و سال

سلام ، چطور میتونم موقع انتخاب تاریخ فقط ماه و سال در منو باز شده نمایش داده بشه و روز ها مخفی بماند
مثلا من میخوام کاربر فقط بتونه برای گزارش گیری بزنه از ماه مهر 1395 تا آبان 1395

popover does not hide when target does not exists anymore

Hi

Thanks for your great plugin 👍

I have an inline form for editing grid row, which one of its controls is MdPersianDateTimePicker (target)
there's a situation when user clicks on target and datetimepicker popover pops up, and then user cancels the form (clicks on form cancel button), the popover does not hide.
I think this is happening because of target element does not exists anymore after that inline form has been removed from body, and what i understood from MD.BootstrapPersianDateTimePicker.js source code, the popover will be hidden based on found target

What can I do to fix this issue?

Regards
Mahyar

Set the current Time in Persian Calendar

In Georgian calendar, when the calendar is displayed, I can see the current time when I want to select a datetime, but in Persian, the default time is set to 00:00:00, but I want to be the current time.
Can you help me regarding this issue?

بعد از نمایش باکس انتخاب تاریخ هیچ چیز عمل نمی کنه

بعد از نمایش باکس انتخاب تاریخ هیچ چیز عمل نمی کنه و این خطا هارو تو کنسول دارم.
هر قدر که روی دکمه ای کلیک میکنم خطاها زیاد تر میشن.

لطفا راه حل ارائه کنید.
@Mds92

`Uncaught TypeError: Cannot set property 'Day' of undefined
at updateDateTimePickerHtml (PersianDateTimePicker.js:1331)
at HTMLTableCellElement. (PersianDateTimePicker.js:1362)

//----------------------------------------------------------------------------

Uncaught TypeError: Cannot read property 'Month' of undefined
at increaseOneMonth (PersianDateTimePicker.js:268)
at updateDateTimePickerHtml (PersianDateTimePicker.js:1289)
at HTMLButtonElement. (PersianDateTimePicker.js:1374)

//----------------------------------------------------------------------------

Uncaught TypeError: Cannot set property 'Year' of undefined
at updateDateTimePickerHtml (PersianDateTimePicker.js:1350)
at HTMLAnchorElement. (PersianDateTimePicker.js:1386)

//----------------------------------------------------------------------------`

[Feature request] GetDateTimeString by it's format

Hi,
Thanks again for this awesome plugin, if it's not such a big ask and ofcourse this doesn't get conflicts with your codes and all, would you please add this function to your plugin? it's about returning true datetime string using it's format, like in C#, right now all I have added to your plugin was this (this is ugly as I have my own way of writing javascript :D this also needs the plugin to already intialized!):

added this into method variable inside your function =>

		getDateTimeByString: function (options) {
			var $this = $(this),
                settings = $this.data(mdPluginName),
                $target = $(settings.TargetSelector),
				$format = (typeof options == "string" ? options : (options ? options.format : 0)),
				$isEnglishNumber = (options ? options.isEnglishNumber : 0) ? true : false;
			if ($target.length <= 0) throw 'TargetSelector is wrong, no elements found';
			return getDateTimeString1($target, $format || 'yyyy/MM/dd HH:mm:ss', $isEnglishNumber, false);
		},

and this inside your function =>

	function getDateTimeString1($target, format, isEnglishNumber, isGregorian) {
		var dateTimeInJsonFormat = {};
		var selectedDateTimeValue = $target.attr(mdSelectedDateTimeAttributeName);
		if (selectedDateTimeValue != undefined && selectedDateTimeValue.trim() != '') {
			try {
				dateTimeInJsonFormat = JSON.parse(selectedDateTimeValue);
			} catch (e) {
				dateTimeInJsonFormat = parsePersianDateTime(getTargetValue($target));
			}
		}
		else
			dateTimeInJsonFormat = parsePersianDateTime(getTargetValue($target));
		var fixedDate = fixPersianDate(dateTimeInJsonFormat.Year, dateTimeInJsonFormat.Month, dateTimeInJsonFormat.Day),
            currentDateNumber = convertToNumber(fixedDate.Year, fixedDate.Month, fixedDate.Day);
		dateTimeInJsonFormat.Year = fixedDate.Year;
		dateTimeInJsonFormat.Month = fixedDate.Month;
		dateTimeInJsonFormat.Day = fixedDate.Day;
		return getDateTimeString(dateTimeInJsonFormat, format, isEnglishNumber, isGregorian)
	}

Usage =>

$('#SampleDateTime').MdPersianDateTimePicker('getDateTimeByString') //returns "۱۳۹۵/۰۸/۲۰ ۱۳:۱۲:۳۸"
$('#SampleDateTime').MdPersianDateTimePicker('getDateTimeByString','yyyyMMddHHmmss') //returns "۱۳۹۵۰۸۲۰۱۳۱۲۳۸"
$('#SampleDateTime').MdPersianDateTimePicker('getDateTimeByString',{format:'yyyyMMddHHmmss',isEnglishNumber:true}) //returns "13950820131238"

Hope you add this 👍
Thanks for this great job :)

نحوه استفاده در کندو گراید

سلام
با تشکر از کنترل زیبا و خوب شما
شاید اینجا جای این سوال نباشه و باید توی فروم ها مطرح بشه
ولی چ جوری توی گراید استفاده میشه بخصوص کندو
ممنون از شما

پیغام خطا هنگام بیلد

سلام
هنگام بیلد خطای زیر رو میده:
Error 1 The name 'RouteConfig' does not exist in the current context D:\Sync\Work\GitHubRepo\MD.BootstrapPersianDateTimePicker\MD.BootstrapPersianDateTimePicker\Global.asax.cs 14 13 MD.BootstrapPersianDateTimePicker

مشکل بودن انتخاب سالهای قبل یا بعد

به نام خدا
با تشکر از تولید بسیار کارا و مفید شما مشکلی که کاربر را خیلی اذیت میکند انتخاب سالهای قدیم است مثلا تاریخ تولد سال 1360 را اگر بخواهیم انتخاب کنیم چون پنج سال پنج سال به عقب برمیگردد باید شش بار روی آن کلیک کنیم تا به آن سال برسیم. خیلی خوب است که اینترفیس انتخاب سال را تغییر دهیدد تا بتوان با اسکرول سالهای قدیمی را نیز براحتی انتخاب کرد. زیرا در حال حاضر استفاده از این پلاگین برای انتخاب سالهای قدیمی بسیار دردسر ساز است و کاربر راحتتر است که خودش تایپ کند.
البته من با اجازه شما کمی در کدهای شما دست بردم و این مشکل رو برای خودم حل کردم که بازه های 100 تایی سال را می آورد به جای 10 تایی که اکنون در دستر هست.
بازم تشکر می کنم از شما و این رو به عنوان یک پیشنهاد اینجا مطرح می کنم. که با کمی تغییر خیلی کاربری آسانتری خواهد داشت.
حیف این پلاگین زیبا و کاربردی شماست.
قطعه کدی که من تغییر دادم:

// افزودن دراپ داون سال
        var $yearDropDown = $calendarHeader.find('[aria-labelledby="dropdownMenuPersianYear"]');
        $yearDropDown.html('');

        var yearForDropDown = dateTimeInJsonFormat == undefined ? currentYearNumber : dateTimeInJsonFormat.Year;
        if (yearForDropDown <= 50)
            yearForDropDown = 51;
        for (var k = yearForDropDown - 50; k <= yearForDropDown + 50; k++) {
            var $dropDownYear = $('<li role="presentation" data-year="' + k + '"><a role="menuitem" tabindex="-1" href="javascript:void(0);" data-name="Md-PersianDateTimePicker-YearNumber">' + toPersianNumber(k) + '</a></li>');
            if (k == currentYearNumber)
                $dropDownYear.addClass('bg-info');
            $yearDropDown.append($dropDownYear);
        }

بعلاوه css های زیر:

.dropdown-menu {
    height:200px;
    overflow:auto;
}

تبدیل به تاریخ میلادی

سلام ، ممنون از کد بسیار خوبی که در اختیار قرار دادین،
می خوام تاریخ برای نمایش و انتخاب به کاربر شمسی باشه اما زمانی که می خوام تاریخ به دیتا بیس بفرستم
میلادی باشه در کد های شما فانکشنی برای کانورت به میلادی دیدم چطور ازش استفاده کنم ؟
var hello = var hello = toGregorian(yy, mm, dd);
alert(hello.gy.toString() + " " + hello.gm.toString() + " " + hello.gd.toString());
همیشه مقدار متغییرهای رشته ای بعد از تبدیل به اینت با دستور پارس اینت ، نن می باشد و تبدیلی صورت نمیگیره

نحوه استفاده در صورت استفاده از کلاس

با سلام
در صورتی که بخوایم به المنت هایی که میخوایم دیت پیکر داشته باشن یک کلاس بدیم و همه اون المنت هایی که اون کلاس رو دارن دیت پیکرو نمایش بدن به صورتی که بعد از انتخاب تاریخ، تاریخ انتخاب شده داخل المنت خودش نمایش داده بشه به چه صورتی باید عمل کرد؟

$('.datePicker').each(function() {
$(this).MdPersianDateTimePicker({
Placement: 'popover',
Trigger: 'click',
EnableTimePicker: false,
TargetSelector: ???????????,
GroupId: '',
ToDate: false,
FromDate: false,
DisableBeforeToday: false,
Disabled: false,
Format: 'yyyy/MM/dd',
IsGregorian: false,
EnglishNumber: true,
});
});

datepicker footer امروز weekday ob1

weekday of today in the footer is off by 1 day

I fixed it by changing line 331 from:

todayDateTimeString = 'امروز، ' + getPersianWeekDay(persianTodayDateTemp[2]) + ' ' + toPersianNumber(currentDayNumber) + ' ' + getPersianMonth(currentMonthNumber) + ' ' + toPersianNumber(currentYearNumber),

to

todayDateTimeString = 'امروز، ' + getPersianWeekDay((persianTodayDateTemp[2]+6)%7) + ' ' + toPersianNumber(currentDayNumber) + ' ' + getPersianMonth(currentMonthNumber) + ' ' + toPersianNumber(currentYearNumber),

(persianTodayDateTemp[2]+6)%7 was chosen rather than simply (persianTodayDateTemp[2]-1) to avoid getting a possibly negative function argument on Sunday.

It seems to work for today, haven't yet tested it for other days though.
Alternatively, relying on the JS native i18n API, replacing the entire RHS with 'امروز، ' + (new Date).toLocaleDateString("fa-IR", {weekday: "long", year: "numeric", month: "long", day: "numeric"}).slice(0, -5), will also do the trick and be less of a hack.

[Feature request] Add date range select support instead of from to

Hi again,
And again thanks for this awesome plugin, I have one feature request which could be amassing to have.
I'm asking for date range select support like bootstrap daterangepicker, it allows you to select between date range which is somehow like your plugin instead of two textbox, it uses only one with buttons to select the range (eg. last 30 days).
Implementing this would really great and support many things we need!

Thanks again for this great work. 👍

using both Jalali and Gregorian

I want to use this calendar with both Jalali and Gregorian configurations. Is it possible? (preferably with a button to switch between them)

باز نشدن تقویم روی خود المنت

با سلام
من از تقویم به صورت زیر استفاده میکنم ولی تقویم روی خود اامنت باز نمیشه و چسبیده به سمت راست صفحه باز میشه:

@using BodySpace.Resources
@model BodySpace.Models.ArticleViewModel

@section styles{
  <link href="~/Content/MdBootstrapPersianDateTimePicker/jquery.Bootstrap-PersianDateTimePicker.min.css" rel="stylesheet" />
}

@using (Html.BeginForm("Create", "Articles", FormMethod.Post, new { @class = "form-horizontal", role = "form", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>@Resource.Article</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form-group">
            @Html.LabelFor(model => model.PublishedOn, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.PublishedOn, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.PublishedOn, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Body, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Body, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Body, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="@Resource.Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

    @Scripts.Render("~/bundles/jqueryval")
    <script src="~/Scripts/MdBootstrapPersianDateTimePicker/jquery.Bootstrap-PersianDateTimePicker.js"></script>
        <script src="~/Scripts/MdBootstrapPersianDateTimePicker/jalaali.js"></script>
    <script type="text/javascript">
        $('#PublishedOn').MdPersianDateTimePicker({
           Placement: 'bottom',
          Trigger: 'focus',
          EnableTimePicker: true,
           TargetSelector: '#PublishedOn',
          GroupId: '',
          ToDate: false,
          FromDate: false,
          EnglishNumber: false,
          Disabled: false,
        });

    </script>

toJalaali is not defined

hi..
i use it in my project with angular 2 and using webpack for publish and i faced to this error :

Error: Uncaught (in promise): Error: Error in :0:0 caused by: toJalaali is not defined
ReferenceError: toJalaali is not defined
at getTodayCalendarInPersian (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:4102:21)
at parsePersianDateTime (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:4490:27)
at HTMLInputElement. (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:5485:41)
at Function.each (http://localhost:3000/dist/vendor4.fe78e1c59da123fedf2a.bundle.js:377:19)
at webpackJsonp.774.a.fn.init.each (http://localhost:3000/dist/vendor4.fe78e1c59da123fedf2a.bundle.js:172:17)
at webpackJsonp.774.a.fn.init.init (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:5456:19)
at webpackJsonp.774.a.fn.init.webpackJsonp.1761.$.fn.MdPersianDateTimePicker (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:5574:27)
at LoginLogComponent.webpackJsonp.1436.LoginLogComponent.ngOnInit (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:1747:30)
at Wrapper_LoginLogComponent.ngDoCheck (/SecurityModule/LoginLogComponent/wrapper.ngfactory.js:24:53)
at CompiledTemplate.proxyViewClass.View_LoginLogComponent_Host0.detectChangesInternal (/SecurityModule/LoginLogComponent/host.ngfactory.js:28:31)
at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:60119:14)
at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:60314:44)
at ViewRef_.detectChanges (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:42788:20)
at RouterOutlet.activate (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:55682:42)
at ActivateRoutes.placeComponentIntoOutlet (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:20426:16)
at getTodayCalendarInPersian (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:4102:21)
at parsePersianDateTime (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:4490:27)
at HTMLInputElement. (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:5485:41)
at Function.each (http://localhost:3000/dist/vendor4.fe78e1c59da123fedf2a.bundle.js:377:19)
at webpackJsonp.774.a.fn.init.each (http://localhost:3000/dist/vendor4.fe78e1c59da123fedf2a.bundle.js:172:17)
at webpackJsonp.774.a.fn.init.init (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:5456:19)
at webpackJsonp.774.a.fn.init.webpackJsonp.1761.$.fn.MdPersianDateTimePicker (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:5574:27)
at LoginLogComponent.webpackJsonp.1436.LoginLogComponent.ngOnInit (http://localhost:3000/dist/3.fe78e1c59da123fedf2a.chunk.js:1747:30)
at Wrapper_LoginLogComponent.ngDoCheck (/SecurityModule/LoginLogComponent/wrapper.ngfactory.js:24:53)
at CompiledTemplate.proxyViewClass.View_LoginLogComponent_Host0.detectChangesInternal (/SecurityModule/LoginLogComponent/host.ngfactory.js:28:31)
at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:60119:14)
at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:60314:44)
at ViewRef_.detectChanges (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:42788:20)
at RouterOutlet.activate (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:55682:42)
at ActivateRoutes.placeComponentIntoOutlet (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:20426:16)
at resolvePromise (http://localhost:3000/dist/polyfills.fe78e1c59da123fedf2a.bundle.js:9539:31) [angular]
at resolvePromise (http://localhost:3000/dist/polyfills.fe78e1c59da123fedf2a.bundle.js:9524:17) [angular]
at http://localhost:3000/dist/polyfills.fe78e1c59da123fedf2a.bundle.js:9573:17 [angular]
at Object.onInvokeTask (http://localhost:3000/dist/vendor1.fe78e1c59da123fedf2a.bundle.js:22553:37) [angular]
at ZoneDelegate.invokeTask (http://localhost:3000/dist/polyfills.fe78e1c59da123fedf2a.bundle.js:9327:40) [angular]
at Zone.runTask (http://localhost:3000/dist/polyfills.fe78e1c59da123fedf2a.bundle.js:9204:47) [ => angular]
at drainMicroTaskQueue (http://localhost:3000/dist/polyfills.fe78e1c59da123fedf2a.bundle.js:9471:35) []
at []

how could i resolve it ?
thanks for any help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.