You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Options.md 25 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. ## Options
  2. <div class="alert alert-info">
  3. <strong>Note</strong>
  4. All options are accessed via the <code>data</code> attribute e.g. <code>$('#datetimepicker').data("DateTimePicker").OPTION()</code>
  5. </div>
  6. ### options()
  7. Returns the components current options object. Note that the changing the values of the returned object does not change the components actual configuration. Use `options(options)` to set the components options massively or the other methods for setting config options individually.
  8. ### options([options])
  9. Takes an object variable with option key:value properties and configures the component. Use this to update multiple options on the component.
  10. ----------------------
  11. ### date
  12. Returns the component's model current date, a `moment` object or `null` if not set.
  13. ####date([newDate])
  14. Takes `string, Date, moment, null` parameter and sets the components model current moment to it. Passing a `null` value unsets the components model current moment. Parsing of the newDate parameter is made using moment library with the `options.format` and `options.useStrict` components configuration.
  15. ##### Throws
  16. * `TypeError` - in case the `newDate` cannot be parsed
  17. ##### Emits
  18. * `dp.change` - In case `newDate` is different from current moment
  19. ----------------------
  20. ### format
  21. Default: false
  22. See [momentjs' docs](http://momentjs.com/docs/#/displaying/format/) for valid formats. Format also dictates what components are shown, e.g. `MM/dd/YYYY` will not display the time picker.
  23. #### format()
  24. Returns the component's `options.format` `string`
  25. #### format(format)
  26. Takes a [moment.js](http://momentjs.com/docs/#/displaying/format/) format `string` and sets the components `options.format`. This is used for displaying and also for parsing input strings either from the input element the component is attached to or the `date()` function.
  27. The parameter can also be a `boolean:false` in which case the format is set to the locale's `L LT`.
  28. **Note:** this is also used to determine if the TimePicker sub component will display the hours in 12 or 24 format. (if 'a' or 'h' exists in the passed `string` then a 12 hour mode is set)
  29. ----------------------
  30. ### dayViewHeaderFormat
  31. Default: 'MMMM YYYY'
  32. Changes the heading of the datepicker when in "days" view.
  33. ![Datepicker Header](img/dpheader.png)
  34. #### dayViewHeaderFormat()
  35. Returns a `string` variable with the currently set `options.dayViewHeaderFormat` option.
  36. #### dayViewHeaderFormat(string)
  37. Takes a `string` value.
  38. Used to customize the header of the day view.
  39. ----------------------
  40. ### extraFormats
  41. Default: false
  42. Allows for several input formats to be valid. See [this PR](https://github.com/Eonasdan/bootstrap-datetimepicker/pull/666).
  43. #### extraFormats()
  44. Returns a `boolean` or array with the `options.extraFormats` option configuration
  45. #### extraFormats(formats)
  46. Takes an array of valid input moment format options.
  47. ----------------------
  48. ### stepping
  49. Default: 1
  50. Number of minutes the up/down arrow's will move the minutes value in the time picker
  51. #### stepping()
  52. Returns a `number` with the `options.stepping` option configuration
  53. #### stepping(number)
  54. Takes a `number`. This be the amount the up/down arrows move the minute value with a time picker.
  55. ----------------------
  56. ### min/maxDate
  57. Default: false
  58. Accepts: date, moment, string
  59. Prevents date/time selections before this date. Will override `defaultDate` and `useCurrent` if either of these settings are the same day since both options are invalid according to the rules you've selected.
  60. #### minDate()
  61. Returns the currently set moment of the `options.minDate` or `false` if not set
  62. #### minDate(minDate)
  63. Takes a minDate `string, Date, moment, boolean:false` parameter and disallows the user to select a moment that is before that moment. If a `boolean:false` value is passed the `options.minDate` parameter is cleared and there is no restriction to the miminum moment the user can select.
  64. **Note:** If the minDate parameter is after the currently selected moment the currently selected moment changes to minDate parameter
  65. ##### Throws
  66. * `TypeError` - if minDate parameter cannot be parsed using the `options.format` and `options.useStrict` configuration settings
  67. * `TypeError` - if minDate parameter is after `options.maxDate`
  68. ##### Emits
  69. * `dp.change` - if the new minDate is after currently selected moment (waiting for #472 to close in order to finalize this part)
  70. * `dp.error` - if the new minDate is after currently selected moment (waiting for #472 to close in order to finalize this part)
  71. ----------------------
  72. #### maxDate()
  73. Returns the currently set moment of the `options.maxDate` or `false` if not set
  74. #### maxDate(maxDate)
  75. Takes a maxDate `string, Date, moment, boolean:false` parameter and disallows the user to select a moment that is after that moment. If a `boolean:false` value is passed `options.maxDate` is cleared and there is no restriction to the maximum moment the user can select.
  76. **Note:** If maxDate is before the currently selected moment the currently selected moment changes to maxDate
  77. ##### Throws
  78. * `TypeError` - if maxDate parameter cannot be parsed using the `options.format` and `options.useStrict` configuration settings
  79. * `TypeError` - if maxDate parameter is before `options.minDate`
  80. ##### Emits
  81. * `dp.change` - if the new maxDate is after currently selected moment (waiting for #472 to close in order to finalize this part)
  82. * `dp.error` - if the new maxDate is after currently selected moment (waiting for #472 to close in order to finalize this part)
  83. ----------------------
  84. ### useCurrent
  85. Default: true
  86. On `show`, will set the picker to the current date/time.
  87. #### useCurrent()
  88. Returns a `boolean` or `string` with the `options.useCurrent` option configuration
  89. #### useCurrent(boolean or string)
  90. Takes a `boolean` or `string`. If a `boolean` true is passed and the components model moment is not set (either through `setDate` or through a valid value on the input element the component is attached to) then the first time the user opens the datetimepicker widget the value is initialized to the current moment of the action. If a false `boolean` is passed then no initialization happens on the input element. You can select the granularity on the initialized moment by passing one of the following strings (`'year', 'month', 'day', 'hour', 'minute'`) in the variable.
  91. If for example you pass `'day'` to the `setUseCurrent` function and the input field is empty the first time the user opens the datetimepicker widget the input text will be initialized to the current datetime with day granularity (ie if currentTime = `2014-08-10 13:32:33` the input value will be initialized to `2014-08-10 00:00:00`)
  92. **Note:** If the `options.defaultDate` is set or the input element the component is attached to has already a value that takes precedence and the functionality of `useCurrent` is not triggered!
  93. ----------------------
  94. ### collapse
  95. Default: true
  96. Using a Bootstraps collapse to switch between date/time pickers.
  97. #### collapse()
  98. Returns a `boolean` of the `options.sideBySide`.
  99. #### collapse(collapse)
  100. Takes a `boolean`. If set to `false` the picker will display similar to `sideBySide` except vertical.
  101. ----------------------
  102. ### locale
  103. Default: moment.locale()
  104. Accepts: string, moment.locale('locale')
  105. See [momentjs](https://github.com/moment/moment/tree/develop/locale) for valid locales.
  106. You must include `moment-with-locales.js` or a local js file.
  107. #### locale()
  108. Returns the currently set locale of the `options.locale`
  109. #### locale(newLocale)
  110. Takes a `string` of any valid [moment locale](https://github.com/moment/moment/tree/develop/locale) e.g. `de` for German.
  111. ##### Throws
  112. * `TypeError` - if the locale is not loaded via a separate script or `moment-with-locales`
  113. ----------------------
  114. ### defaultDate
  115. Default: false
  116. Accepts: date, moment, string
  117. Sets the picker default date/time. Overrides `useCurrent`
  118. #### defaultDate()
  119. Returns a `moment` with the `options.defaultDate` option configuration or `false` if not set
  120. #### defaultDate(defaultDate)
  121. Takes a `string, Date, moment, boolean:false`. Will set the picker's inital date. If a `boolean:false` value is passed the `options.defaultDate` parameter is cleared.
  122. * `TypeError` - if the provided date pass validation, including `disabledDates`, `enabledDates`, `minDate`, `maxDate`, and `daysOfWeekDisabled`
  123. * `TypeError` - if the provided date cannot be parsed by momentjs
  124. ----------------------
  125. ### en/disabledDates
  126. Default: false
  127. Accepts: array of [date, moment, string]
  128. #### disabledDates()
  129. Returns an array with the currently set disabled dates on the component.
  130. #### disabledDates(dates)
  131. Takes an `[` `string` or `Date` or `moment` `]` of values and disallows the user to select those days. Setting this takes precedence over `options.minDate`, `options.maxDate` configuration. Also calling this function removes the configuration of options.enabledDates if such exist.
  132. **Note:** These values are matched with `Day` granularity.
  133. ----------------------
  134. #### enabledDates()
  135. Returns an array with the currently set enabled dates on the component.
  136. #### enabledDates(dates)
  137. Takes an `[` `string` or `Date` or `moment` `]` of values and allows the user to select only from those days. Setting this takes precedence over `options.minDate`, `options.maxDate` configuration. Also calling this function removes the configuration of options.disabledDates if such exist.
  138. **Note:** These values are matched with `Day` granularity.
  139. ----------------------
  140. ### icons
  141. Default: {
  142. time: 'glyphicon glyphicon-time',
  143. date: 'glyphicon glyphicon-calendar',
  144. up: 'glyphicon glyphicon-chevron-up',
  145. down: 'glyphicon glyphicon-chevron-down',
  146. previous: 'glyphicon glyphicon-chevron-left',
  147. next: 'glyphicon glyphicon-chevron-right',
  148. today: 'glyphicon glyphicon-screenshot',
  149. clear: 'glyphicon glyphicon-trash',
  150. close: 'glyphicon glyphicon-remove'
  151. }
  152. Accepts: object with all or some of the parameters above
  153. Change the default icons for the pickers functions.
  154. #### icons()
  155. Returns an `Ojbect` of `options.icons`
  156. #### icons(icons)
  157. Takes an `Ojbect` of `strings`.
  158. ##### Throws
  159. * `TypeError` - if icons parameter is not an `Ojbect`
  160. ----------------------
  161. ### useStrict
  162. Default: false
  163. Defines if moment should use strict date parsing when considering a date to be valid.
  164. #### useStrict()
  165. Returns a `boolean` of the `options.useStrict`
  166. #### useStrict(useStrict)
  167. Takes a `boolean`. If `useStrict` is `true`, momentjs parsing rules will be stricter when determining if a date is valid or not.
  168. ----------------------
  169. ### sideBySide
  170. Default: false
  171. Shows the picker side by side when using the time and date together.
  172. ![SideBySide](img/sideBySide.png)
  173. #### sideBySide()
  174. Returns a `boolean` of the `options.sideBySide`.
  175. #### sideBySide(sideBySide)
  176. Takes a `boolean`. If `sideBySide` is `true` and the time picker is used, both components will display side by side instead of collapsing.
  177. ----------------------
  178. ### daysOfWeekDisabled
  179. Default: []
  180. Accepts: array of numbers from 0-6
  181. Disables the section of days of the week, e.g. weekends.
  182. #### daysOfWeekDisabled()
  183. Returns an array with the `options.daysOfWeekDisabled` configuration setting of the component.
  184. #### daysOfWeekDisabled(daysOfWeek)
  185. Takes an `[` `Number`:`0` to `6` `]` and disallow the user to select weekdays that exist in this array. This has lower priority over the `options.minDate`, `options.maxDate`, `options.disabledDates` and `options.enabledDates` configuration settings.
  186. ##### Emits
  187. * `dp.change` - if the currently selected moment falls in the values passed on the daysOfWeek parameter. (waiting for #472 to close in order to finalize this part)
  188. * `dp.error` - if the currently selected moment falls in the values passed on the daysOfWeek parameter. (waiting for #472 to close in order to finalize this part)
  189. ----------------------
  190. ### calendarWeeks
  191. Default: false
  192. Shows the week of the year to the left of first day of the week.
  193. ![calendarWeek](img/calendarWeeks.png)
  194. #### calendarWeeks()
  195. Returns a `boolean` with the current `options.calendarWeeks` option configuration
  196. #### calendarWeeks(boolean)
  197. Takes a `boolean` variable to set if the week numbers will appear to the left on the days view
  198. ----------------------
  199. ### viewMode
  200. Default: 'days'
  201. Accepts: 'decades','years','months','days'
  202. The default view to display when the picker is shown.
  203. **Note**: To limit the picker to selecting, for instance the year and month, use `format: MM/YYYY`.
  204. #### viewMode()
  205. Returns a `string` of the `options.viewMode`.
  206. #### viewMode(newViewMode)
  207. Takes a `string`. Valid values are `'days'`, `'months'`, `'years'` and `'decades'`
  208. ##### Throws
  209. * `TypeError` - if `newViewMode` parameter is not an a `string` or if `newViewMode` is not a valid value.
  210. ----------------------
  211. ### toolbarPlacement
  212. Default: 'default'
  213. Accepts: 'default', 'top', 'bottom'
  214. Changes the placement of the icon toolbar.
  215. ![toolbarPlacement](img/toolbarPlacement.png)
  216. #### toolbarplacement()
  217. Returns a `string` variable with the currently set `options.toolbarplacement` option.
  218. #### toolbarplacement(string)
  219. Takes a `string` value. Valid values are `'default'`, `'top'` and `'bottom'`.
  220. Changes the placement of the toolbar where the today, clear, component switch icon are located.
  221. ----------------------
  222. ### showTodayButton
  223. Default: false
  224. Show the "Today" button in the icon toolbar.
  225. Clicking the "Today" button will set the calendar view and set the date to `now`.
  226. #### showTodayButton()
  227. Returns a `boolean` variable with the currently set `options.showTodayButton` option.
  228. #### showTodayButton(boolean)
  229. Takes a `boolean` variable to set if the Today button will appear on the widget
  230. ----------------------
  231. ### showClear
  232. Default: false
  233. Show the "Clear" button in the icon toolbar.
  234. Clicking the "Clear" button will set the calendar to null.
  235. #### showClear()
  236. Returns a `boolean` variable with the currently set `options.showClear` option.
  237. #### showClear(boolean)
  238. Takes a `boolean` variable to set if the clear date button will appear on the widget
  239. ----------------------
  240. ### showClose
  241. Default: false
  242. Show the "Close" button in the icon toolbar.
  243. Clicking the "Close" button will call `hide()`
  244. #### showClose()
  245. Returns a `boolean` variable with the currently set `options.showClose` option.
  246. #### showClose(boolean)
  247. Takes a `boolean` value.
  248. If `true`, an icon will be displayed on the toolbar that will hide the picker
  249. ----------------------
  250. ### widgetPositioning
  251. Default: {
  252. horizontal: 'auto'
  253. vertical: 'auto'
  254. }
  255. Accepts: object with the all or one of the parameters above
  256. horizontal: 'auto', 'left', 'right'
  257. vertical: 'auto', 'top', 'bottom'
  258. #### widgetPositioning()
  259. Returns the currently set `options.widgetPositioning` object containing two keys `horizontal` and `vertical`
  260. #### widgetPositioning(positioningObject)
  261. Takes an object parameter that can contain two keys `vertical` and `horizontal` each having a value of `'auto', 'top', 'bottom'` for `vertical` and `'auto', 'left', 'right'` for `horizontal` which defines where the dropdown with the widget will appear relative to the input element the component is attached to.
  262. `'auto'` is the default value for both `horizontal` and `vertical` keys and it tries to automatically place the dropdown in a position that is visible to the user. Usually you should not override those options unless you have a special need in your layout.
  263. ----------------------
  264. ### widgetParent
  265. Default: null
  266. Accepts: string or jQuery object
  267. On picker show, places the widget at the identifier (string) or jQuery object **if** the element has css `position: 'relative'`
  268. #### widgetParent()
  269. Returns a `$(element)` variable with the currently set `options.widgetParent` option.
  270. #### widgetParent(widgetParent)
  271. Takes a `string` or `$(element)` value.
  272. ----------------------
  273. ### keepOpen
  274. Default: false
  275. Will cause the date picker to stay open after selecting a date.
  276. #### keepOpen()
  277. Returns a `boolean` variable with the currently set `options.keepOpen` option.
  278. #### keepOpen(boolean)
  279. Takes a `boolean` value.
  280. ----------------------
  281. ### inline
  282. Default: false
  283. Will display the picker inline without the need of a input field. This will also hide borders and shadows.
  284. #### inline()
  285. Returns a `boolean` variable with the currently set `options.inline` option.
  286. #### inline(boolean)
  287. Takes a `boolean` value.
  288. ----------------------
  289. ### keepInvalid
  290. <small>4.7.14</small>
  291. Default: false
  292. Will cause the date picker to **not** revert or overwrite invalid dates.
  293. #### keepInvalid()
  294. Returns a `string` variable with the currently set `options.keepInvalid` option.
  295. #### keepInvalid(boolean)
  296. Takes a `boolean` value.
  297. If `true`, invalid dates will not be reverted to a previous selection or changed.
  298. ----------------------
  299. ### keyBinds
  300. Default: up: function (widget) {
  301. if (widget.find('.datepicker').is(':visible')) {
  302. this.date(this.date().clone().subtract(7, 'd'));
  303. } else {
  304. this.date(this.date().clone().add(1, 'm'));
  305. }
  306. },
  307. down: function (widget) {
  308. if (!widget) {
  309. this.show();
  310. }
  311. else if (widget.find('.datepicker').is(':visible')) {
  312. this.date(this.date().clone().add(7, 'd'));
  313. } else {
  314. this.date(this.date().clone().subtract(1, 'm'));
  315. }
  316. },
  317. 'control up': function (widget) {
  318. if (widget.find('.datepicker').is(':visible')) {
  319. this.date(this.date().clone().subtract(1, 'y'));
  320. } else {
  321. this.date(this.date().clone().add(1, 'h'));
  322. }
  323. },
  324. 'control down': function (widget) {
  325. if (widget.find('.datepicker').is(':visible')) {
  326. this.date(this.date().clone().add(1, 'y'));
  327. } else {
  328. this.date(this.date().clone().subtract(1, 'h'));
  329. }
  330. },
  331. left: function (widget) {
  332. if (widget.find('.datepicker').is(':visible')) {
  333. this.date(this.date().clone().subtract(1, 'd'));
  334. }
  335. },
  336. right: function (widget) {
  337. if (widget.find('.datepicker').is(':visible')) {
  338. this.date(this.date().clone().add(1, 'd'));
  339. }
  340. },
  341. pageUp: function (widget) {
  342. if (widget.find('.datepicker').is(':visible')) {
  343. this.date(this.date().clone().subtract(1, 'M'));
  344. }
  345. },
  346. pageDown: function (widget) {
  347. if (widget.find('.datepicker').is(':visible')) {
  348. this.date(this.date().clone().add(1, 'M'));
  349. }
  350. },
  351. enter: function () {
  352. this.hide();
  353. },
  354. escape: function () {
  355. this.hide();
  356. },
  357. 'control space': function (widget) {
  358. if (widget.find('.timepicker').is(':visible')) {
  359. widget.find('.btn[data-action="togglePeriod"]').click();
  360. }
  361. },
  362. t: function () {
  363. this.date(moment());
  364. },
  365. 'delete': function () {
  366. this.clear();
  367. }
  368. Allows for custom events to fire on keyboard press.
  369. #### keyBinds()
  370. Returns a `string` variable with the currently set `options.keyBinds` option.
  371. #### keyBinds(object)
  372. Takes an `object` value.
  373. Allows for several keyBinding functions to be specified for ease of access or accessibility. See the options page for defaults.
  374. ----------------------
  375. ### debug
  376. <small>4.7.14</small>
  377. Default: false
  378. Will cause the date picker to stay open after a `blur` event.
  379. ----------------------
  380. ### ignoreReadonly
  381. <small>4.7.14</small>
  382. Default: false
  383. Allow date picker show event to fire even when the associated input element has the `readonly="readonly"`property.
  384. #### ignoreReadonly()
  385. Returns a `boolean` variable with the currently set `options.ignoreReadonly` option.
  386. #### ignoreReadonly(boolean)
  387. Takes a `boolean` value.
  388. Set this to `true` to allow the picker to be used even if the input field is `readonly`. This will **not** bypass the `disabled` property
  389. ----------------------
  390. ### disabledTimeIntervals
  391. <small>4.14.30</small>
  392. Default: false
  393. Disables time selection between the given `moments`.
  394. #### disabledTimeIntervals()
  395. Returns an `array` variable with the currently set `options.disabledTimeIntervals` option.
  396. #### disabledTimeIntervals(array)
  397. Takes a `array` value.
  398. The array **must** be in the following format `[moment(),moment()]`
  399. For example:
  400. disabledTimeIntervals: [[moment({ h: 0 }), moment({ h: 8 })], [moment({ h: 18 }), moment({ h: 24 })]]
  401. Will disable times between 12-8am and 6-12pm today
  402. ----------------------
  403. ### allowInputToggle
  404. <small>4.14.30</small>
  405. Default: false
  406. If `true`, the picker will show on textbox focus and icon click when used in a button group.
  407. #### allowInputToggle()
  408. Returns a `boolean` variable with the currently set `options.allowInputToggle` option.
  409. #### allowInputToggle(boolean)
  410. Takes a `boolean` value.
  411. If `true`, the picker will show on textbox focus and icon click when used in a button group
  412. ----------------------
  413. ### focusOnShow
  414. <small>4.14.30</small>
  415. Default: true
  416. If `false`, the textbox will not be given focus when the picker is shown.
  417. #### focusOnShow()
  418. Returns a `boolean` variable with the currently set `options.focusOnShow` option.
  419. #### focusOnShow(boolean)
  420. Takes a `boolean` value.
  421. If `false`, the textbox will not be given focus when the picker is shown
  422. ----------------------
  423. ### en/disabledHours
  424. <small>4.14.30</small> Issue: #851
  425. Default: false
  426. #### disabledHours()
  427. Returns an `array` variable with the currently set `options.en/disabledHours` option.
  428. #### disabledHours(boolean)
  429. Takes a `array` value.
  430. Must be in 24 hour format. Will allow or disallow hour selections (much like `disabledTimeIntervals`) but will affect all days.
  431. Like `en/disabledDates`, these options are mutually exclusive and will reset one of the options back to false.
  432. disabledHours: [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23, 24]
  433. enabledHours: [9, 10, 11, 12, 13, 14, 15, 16]
  434. ----------------------
  435. ### viewDate
  436. <small>4.14.30</small>
  437. Default: false
  438. This will change the `viewDate` without changing or setting the selected date.
  439. ----------------------
  440. ### parseInputDate
  441. <small>4.14.30</small> Issue #1095
  442. #### parseInputDate()
  443. Returns a `function` with the currently set `options.parseInputDate`
  444. #### parseInputDate(function)
  445. Takes a `function`
  446. Allows custom input formatting For example: the user can enter 'yesterday' or '30 days ago'.
  447. Example:
  448. ```
  449. var parseRelativeDate = function(relativeDate) {
  450. switch (relativeDate) {
  451. case 'today':
  452. return moment()
  453. case 'yesterday':
  454. return moment().subtract(1, 'day');
  455. default:
  456. return moment()
  457. .subtract(Number(relativeDate.replace("days ago", "").trim()), 'days');
  458. }
  459. }
  460. var parseInputDate = function(inputDate) {
  461. var relativeDatePattern = /today|yesterday|[0-9]+\s+(days ago)/,
  462. resultDate;
  463. if (moment.isMoment(inputDate) || inputDate instanceof Date) {
  464. resultDate = moment(inputDate);
  465. } else {
  466. var relativeDate = inputDate.match(relativeDatePattern),
  467. parseDate = null;
  468. if (relativeDate !== null)
  469. parseDate = this.parseRelativeDate(inputDate.match(relativeDatePattern)[0]);
  470. else
  471. parseDate = moment();
  472. resultDate = moment(parseDate, "YYYY-MM-DD");
  473. }
  474. return resultDate;
  475. }
  476. ```
  477. ----------------------
  478. ### tooltips
  479. <small>4.15.35</small>
  480. ```
  481. tooltips: {
  482. today: 'Go to today',
  483. clear: 'Clear selection',
  484. close: 'Close the picker',
  485. selectMonth: 'Select Month',
  486. prevMonth: 'Previous Month',
  487. nextMonth: 'Next Month',
  488. selectYear: 'Select Year',
  489. prevYear: 'Previous Year',
  490. nextYear: 'Next Year',
  491. selectDecade: 'Select Decade',
  492. prevDecade: 'Previous Decade',
  493. nextDecade: 'Next Decade',
  494. prevCentury: 'Previous Century',
  495. nextCentury: 'Next Century'
  496. }
  497. ```
  498. This will change the `tooltips` over each icon to a custom string.
  499. #### tooltips()
  500. Returns an `Ojbect` of `options.tooltips`
  501. #### tooltips(tooltips)
  502. Takes an `Ojbect` of `strings`.
  503. ##### Throws
  504. * `TypeError` - if tooltips parameter is not an `Ojbect`
  505. ----------------------
  506. ### timeZone
  507. <small>4.17.37</small>
  508. ```
  509. timeZone: ''
  510. ```
  511. Allows the setting of the Time Zone. You must include [`moment-timezone.js`](http://momentjs.com/timezone/) and `moment-timzone` data. See moment timezone documentation for usage.
  512. #### timeZone()
  513. Returns an `string` of `options.timeZone`
  514. #### timeZone(timeZone)
  515. Takes an `string` of a valid timezone.
  516. ##### Throws
  517. * `TypeError` - if tooltips parameter is not an `string`