new Datepicker([isHijriMode[, fullYear[, monthIndex[, firstDay[, language[, colorTheme[, width]]]]]]]);
-
isHijriMode
(optional)
Boolean value representing the dates mode
true
: Hijri dates
false
: Gregorian dates
Default:false
-
fullYear
(optional)
Integer value representing the full year. Allow value below 1 (0 or negative value) that indicates before Hijra/Gregorian era. Value 0 for 1 BH/BE, -1 for 2 BH/BE, and so forth.
Default: current year -
monthIndex
(optional)
Integer value representing the month, beginning with 0 for Muharram/January to 11 for Dhul-Hijja/December.
Default: index of current month -
firstDay
(optional)
Integer value representing the first day of week (0-6).
Default:1
(Monday) -
language
(optional)
String value representing the language used by the widget. Currently three languages are supported.
"ar"
: Arabic
"en"
: English
"id"
: Indonesian
Default:"en"
-
colorTheme
(optional)
Integer value representing the color index (0-22) or string value representing the color theme used by the widget.
0
or"amber"
1
or"aqua"
2
or"black"
3
or"blue"
4
or"blue-grey"
"
5
or"brown"
6
or"cyan"
7
or"dark-grey"
8
or"deep-orange"
9
or"deep-purple"
10
or"green"
11
or"grey"
12
or"indigo"
13
or"khaki"
14
or"light-blue"
15
or"light-green"
16
or"lime"
17
or"orange"
18
or"pink"
19
or"purple"
20
or"red"
21
or"teal"
22
or"yellow"
Default: random color theme -
width
(optional)
Numeric value representing the width of the widget (280-600) in pixel.
Default:300
pixel
-
.attachTo(parentElement)
Attach this widget element into a parent HTML element designated byparentElement
. -
.getElement()
Returns this widget element. -
.getOppositePickedDate()
Returns an opposite date instance of current dates mode. If the current dates mode is Gregorian then this method will return aHijriDate
instance, whereas if the current dates mode is Hijri then aDate
instance will be returned. -
.getPickedDate()
Returns an instance ofDate
orHijriDate
depend on widget current dates mode. To conserve the memory, it's important to note that each instance returned by a call to this method, all of them are the same instance and only differs from the moment it represents. -
.hide()
Hides this widget. -
.pick()
Shows this widget. This is the same with.show()
method. -
.resetDate(fullYear, monthIndex)
Resets the dates with an integer value pointed byfullYear
and an integer value pointed bymonthIndex
. -
.setFirstDayOfWeek(firstDay)
Sets the first day of week with an integer value (0-6) pointed byfirstDay
. -
.setFullYear(fullYear)
Sets the full year with an integer value pointed byfullYear
. -
.setHijriMode(hijriMode)
Sets the dates mode with a boolean value pointed byhijriMode
.
true
: Hijri dates
false
: Gregorian dates -
.setLanguage(language)
Sets the language used by this widget with a string value pointed bylanguge
.
"ar"
: Arabic
"en"
: English
"id"
: Indonesian -
.setMonth(monthIndex)
Sets the month index with an integer value (0-11) pointed bymonthIndex
. -
.setTheme([colorTheme])
Sets the widget color theme with an integer value (0-22) as color index or a string value as color name pointed bycolorTheme
. If thiscolorTheme
isn't specified then a random color theme will be applied.
0
or"amber"
1
or"aqua"
2
or"black"
3
or"blue"
4
or"blue-grey"
"
5
or"brown"
6
or"cyan"
7
or"dark-grey"
8
or"deep-orange"
9
or"deep-purple"
10
or"green"
11
or"grey"
12
or"indigo"
13
or"khaki"
14
or"light-blue"
15
or"light-green"
16
or"lime"
17
or"orange"
18
or"pink"
19
or"purple"
20
or"red"
21
or"teal"
22
or"yellow"
-
.setTime(time)
Sets the dates to an integer value pointed bytime
as the time represented by number of milliseconds. -
.setWidth(width)
Sets the widget width in pixel with a numeric value (280-600) pointed bywidth
. -
.show()
Shows the widget. This is the same with.pick()
method. -
.today()
Sets the dates to current year and month.
.onPicked
Assign this property to a function that do some processes when a date was picked. Please note that every time a date is picked, the.hide()
method always called afterwards.
For example:let datepicker = new Datepicker(); datepicker.onPicked = function() { // do stuff };
By using this library, the following methods will be added to both Date.prototype
and HijriDate.prototype
instances.
-
.getDateString()
Returns the picked dates as a human readable string in accordance with predetemined dates mode (Gregorian or Hijri). For example "Friday, 4 January 2019 AD" for the Gregorian dates mode or "Jumu'ah, 27 Rabi'ul-Akhir 1440 H" for the Hijri dates mode. -
.getMonthName([monthIndex])
Returns the name of desired month index (0-11) that pointed bymonthIndex
as a human readable string ("January"-"December" or "Muharram"-"Dhul-Hijja"). IfmonthIndex
is omitted, instead the current month's name will be returned. -
.getWeekdayName([day])
Returns the name of desired day of week (0-6) that pointed byday
as a human readable string ("Sunday"-"Saturday" or "Ahad"-"Sabt"). Ifday
is omitted, instead the name of current day of week will be returned. -
.getWeekdayShortName([day])
Returns the short name of desired day of week (0-6) that pointed byday
as a human readable string ("Sun"-"Sat" or "Ahd"-"Sab"). Ifday
is omitted, instead the short name of current day of week will be returned. -
.getYearString([fullYear])
Returns the desired full year in integer value that pointed byfullYear
followed by era suffix as a human readable string. IffullYear
is omitted, instead the string of current full year will be returned.