4.2.6 • Published 12 months ago

md.bootstrappersiandatetimepicker v4.2.6

Weekly downloads
80
License
MIT
Repository
github
Last release
12 months ago

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 [ ]

NameValuesDescriptionSample
placementtop, right, bottom, leftPosition of date time picker
triggerclick, mouse down, focus, ...Event to show date time picker
enableTimePickerfalse, trueTime picker visibility
targetTextSelectorStringCSS selector to show selected date as format property into it'#TextBoxId'
targetDateSelectorStringCSS selector to save selected date into it'#InputHiddenId'
toDatefalse, trueWhen you want to set date picker as toDate to enable date range selecting
fromDatefalse, trueWhen you want to set date picker as fromDate to enable date range selecting
groupIdStringWhen you want to use toDate, fromDate you have to enter a group id to specify date time pickers'dateRangeSelector1'
disabledfalse, trueDisable date time picker
textFormatStringformat of selected date to show into targetTextSelector'yyyy/MM/dd HH:mm:ss'
dateFormatStringformat of selected date to save into targetDateSelector'yyyy/MM/dd HH:mm:ss'
isGregorianfalse, trueIs calendar Gregorian
inLinefalse, trueIs date time picker in line
modalModefalse, trueOpen in modal mode, suitable for smart phones
selectedDateundefined, DateSelected date as JavaScript Date objectnew Date('2018/9/30')
selectedDateToShownew Date(), DateSelected date to start calendar from it as JavaScript Date objectnew Date('2018/9/30')
selectedRangeDateArray: Date[]Selected range date as JavaScript Date objectnew Date('2020/8/5'), new Date('2020/8/15')
yearOffsetNumberNumber of years to select in year selector30
holidaysArray: Date[]Array of holidays to show in date time picker as holidaynew Date(), new Date(2017, 3, 2)
disabledDatesArray: Date[]Array of disabled dates to prevent user to select themnew Date(2017, 1, 1), new Date(2017, 1, 2)
specialDatesArray: Date[]Array of dates to mark some dates as specialnew Date(2017, 2, 1), new Date(2017, 3, 2)
disabledDaysArray: number[]Array of disabled week days to prevent user to select themDisable all "Thursday", "Friday" in persian 5, 6
disableBeforeTodayfalse, trueDisable days before today
disableAfterTodayfalse, trueDisable days after today
disableBeforeDateDateDisable days before this Datenew Date(2018, 11, 12)
disableAfterDateDateDisable days after this Datenew Date(2018, 12, 11)
rangeSelectorfalse, trueEnables rangeSelector feature on date time picker
monthsToShowNumeric array with 2 items, 0 ,0To show, number of month before and after selected date in date time picker, first item is for before month, second item is for after month1, 1
persianNumberfalse, trueConvert numbers to persian characters
calendarViewOnChange(date)functionEvent fires on date picker's view change
onDayClick(event)functionEvent fires on day cell click

String format:

FormatEnglish DescriptionPersian Description
yyyyYear, 4 digitsسال چهار رقمی
yyYear, 2 digitsسال دو رقمی
MMMMMonth nameنام ماه
MMMonth, 2 digitsعدد دو رقمی ماه
MMonth, 1 digitعدد تک رقمی ماه
ddddWeek day nameنام روز هفته
ddMonth's day, 2 digitsعدد دو رقمی روز
dMonth's day, 1 digitعدد تک رقمی روز
HHHour, 2 digits - 0 - 24عدد دو رقمی ساعت با فرمت 0 تا 24
HHour, 1 digit - 0 - 24عدد تک رقمی ساعت با فرمت 0 تا 24
hhHour, 2 digits - 0 - 12عدد دو رقمی ساعت با فرمت 0 تا 12
hHour, 1 digit - 0 - 12عدد تک رقمی ساعت با فرمت 0 تا 12
mmMinute, 2 digitsعدد دو رقمی دقیقه
mMinute, 1 digitعدد تک رقمی دقیقه
ssSecond, 2 digitsثانیه دو رقمی
sSecond, 1 digitثانیه تک رقمی
ttAM / PMب.ظ یا ق.ظ
tA / Pحرف اول از ب.ظ یا ق.ظ

Functions:

NameReturn ValueDescriptionSample
showvoidshow date pickerdtp1Instance.show()
hidevoidhide date pickerdtp1Instance.hide()
togglevoidshow or hide date pickerdtp1Instance.toggle()
enablevoidenable date pickerdtp1Instance.enable()
disablevoiddisable date pickerdtp1Instance.disable()
updatePositionvoidupdate position of date pickerdtp1Instance.updatePosition()
updateSelectedDateTextvoidupdate targetTextSelector textdtp1Instance.updateSelectedDateText()
disposevoiddispose date pickerdtp1Instance.dispose()
getBsPopoverInstancebootstrap.Popoverreturn instance of bootstrap popoverconst bsPopover = dtp1Instance.getBsPopoverInstance()
getBsModalInstancebootstrap.Modalreturn instance of bootstrap modalconst bsModal = dtp1Instance.getBsModalInstance()
updateOptionvoidupdate one option of date pickerdtp1Instance.updateOption('isGregorian', false)
updateOptionsvoidupdate one option of date pickerdtp1Instance.updateOptions({ isGregorian: false, inLine: false, ... })
getInstanceMdsPersianDateTimePickerstatic method, get instance of MdsDatePicker by an element objconst jalaliObj = mds.MdsPersianDateTimePicker.getInstance(document.getELementById('IdOfElement'));
getTextstringGet selected date textconst txt = dtp1Instance.getText()
getDateDateGet selected dateconst dateObj = dtp1Instance.getDate()
getDateRangefromDate, toDate: Date[]Get selected date rangedtp1Instance.getDateRange();
setDatevoidSet selected datetime with Date object argumentdtp1Instance.setDate(new Date('2021/09/22'));
setDatePersianvoidSet selected datetime with Date object argumentdtp1Instance.setDatePersian(1400, 06, 31);
setDateRangevoidSet selected datetime range with Date object argumentdtp1Instance.setDateRange(new Date('2021/09/04'), new Date('2021/09/22'));
clearDatevoidclear selected datedtp1Instance.clearDate();
convertDateToStringstringutility & static method, convert date object to stringconst dateStr = mds.MdsPersianDateTimePicker.convertDateToString(date: new Date(), isGregorian: false, format: 'yyyy/MM/dd');
convertDateToJalalijsonutility & static method, convert date object to Jalaliconst 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.

4.2.6

12 months ago

4.2.5

1 year ago

4.2.3

1 year ago

4.2.2

1 year ago

4.2.4

1 year ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.0

3 years ago

4.1.1

3 years ago

4.0.0

3 years ago

3.11.5

3 years ago

3.11.4

3 years ago

3.11.3

3 years ago

3.11.0

3 years ago

3.11.2

3 years ago

3.11.1

3 years ago

3.10.1

3 years ago

3.10.0

3 years ago

3.9.2

4 years ago

3.9.1

4 years ago

3.8.0

4 years ago

3.7.4

4 years ago

3.7.3

4 years ago

3.7.2

4 years ago

3.7.1

4 years ago

3.7.0

4 years ago

3.6.3

5 years ago

3.6.2

5 years ago

3.6.1

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.8

5 years ago

3.4.7

5 years ago

3.4.6

5 years ago

3.4.5

5 years ago

3.4.4

5 years ago

3.4.3

5 years ago

3.4.2

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.8

5 years ago

3.3.7

5 years ago

3.3.6

5 years ago

3.3.5

5 years ago

3.3.4

5 years ago

3.3.3

5 years ago

3.3.2

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.9

5 years ago

3.2.8

6 years ago

3.2.7

6 years ago

3.2.6

6 years ago

3.2.5

6 years ago

3.2.4

6 years ago

3.2.3

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.9

6 years ago

3.1.8

6 years ago

3.1.7

6 years ago

3.1.6

6 years ago

3.1.5

6 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

7 years ago