├── .github
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── PULL_REQUEST_TEMPLATE.md
└── stale.yml
├── CHANGE.md
├── LICENSE.md
├── README.md
├── composer.json
└── src
├── DateControl.php
├── DateControlAsset.php
├── DateFormatterAsset.php
├── Module.php
├── assets
└── js
│ ├── datecontrol.js
│ └── datecontrol.min.js
├── controllers
└── ParseController.php
└── locales
├── ar
└── dateSettings.php
├── bg
└── dateSettings.php
├── ca
└── dateSettings.php
├── cs
└── dateSettings.php
├── cy
└── dateSettings.php
├── da
└── dateSettings.php
├── de
└── dateSettings.php
├── el
└── dateSettings.php
├── es
└── dateSettings.php
├── et
└── dateSettings.php
├── fa
└── dateSettings.php
├── fi
└── dateSettings.php
├── fr
└── dateSettings.php
├── gl
└── dateSettings.php
├── he
└── dateSettings.php
├── hr
└── dateSettings.php
├── hu
└── dateSettings.php
├── id
└── dateSettings.php
├── is
└── dateSettings.php
├── it
└── dateSettings.php
├── ja
└── dateSettings.php
├── ka
└── dateSettings.php
├── kk
└── dateSettings.php
├── kr
└── dateSettings.php
├── lt
└── dateSettings.php
├── lv
└── dateSettings.php
├── mk
└── dateSettings.php
├── ms
└── dateSettings.php
├── nb
└── dateSettings.php
├── nl-BE
└── dateSettings.php
├── nl
└── dateSettings.php
├── no
└── dateSettings.php
├── pl
└── dateSettings.php
├── pt-BR
└── dateSettings.php
├── pt
└── dateSettings.php
├── ro
└── dateSettings.php
├── rs-latin
└── dateSettings.php
├── rs
└── dateSettings.php
├── ru
└── dateSettings.php
├── sk
└── dateSettings.php
├── sl
└── dateSettings.php
├── sq
└── dateSettings.php
├── sv
└── dateSettings.php
├── sw
└── dateSettings.php
├── th
└── dateSettings.php
├── tr
└── dateSettings.php
├── ua
└── dateSettings.php
├── vi
└── dateSettings.php
├── zh-CN
└── dateSettings.php
└── zh-TW
└── dateSettings.php
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing to yii2-datecontrol
2 | ================================
3 | Looking to contribute something to yii2-datecontrol? **Here's how you can help.**
4 |
5 | Please take a moment to review this document in order to make the contribution
6 | process easy and effective for everyone involved.
7 |
8 | Following these guidelines helps to communicate that you respect the time of
9 | the developers managing and developing this open source project. In return,
10 | they should reciprocate that respect in addressing your issue or assessing
11 | patches and features.
12 |
13 | Using the issue tracker
14 | -----------------------
15 | When [reporting bugs][reporting-bugs] or
16 | [requesting features][requesting-features], the
17 | [issue tracker on GitHub][issue-tracker] is the recommended channel to use.
18 |
19 | The issue tracker **is not** a place for support requests. Refer the
20 | [extension documentation](http://demos.krajee.com/datecontrol),
21 | [extension demos](http://demos.krajee.com/datecontrol-demo) and/or refer to the
22 | [webtips Q & A forum](http://webtips.krajee.com/questions) which are the better places to get help.
23 |
24 | Reporting bugs with yii2-datecontrol
25 | ------------------------------------
26 | We really appreciate clear bug reports that _consistently_ show an issue
27 | _within yii2-datecontrol_.
28 |
29 | The ideal bug report follows these guidelines:
30 |
31 | 1. **Use the [GitHub issue search][issue-search]** — Check if the issue
32 | has already been reported.
33 | 2. **Check if the issue has been fixed** — Try to reproduce the problem
34 | using the code in the `master` branch.
35 | 3. **Isolate the problem** — Try to share a demo or a test case that
36 | consistently reproduces the problem.
37 |
38 | Please try to be as detailed as possible in your bug report, especially if an
39 | isolated test case cannot be made. Some useful questions to include the answer
40 | to are:
41 |
42 | - What steps can be used to reproduce the issue?
43 | - What is the bug and what is the expected outcome?
44 | - What browser(s) and Operating System have you tested with?
45 | - Does the bug happen consistently across all tested browsers?
46 | - What version of jQuery are you using? And what version of yii2-datecontrol?
47 | - Are you using yii2-datecontrol with other plugins?
48 |
49 | All of these questions will help others fix and identify any potential bugs.
50 |
51 | Requesting features in yii2-datecontrol
52 | ------------------------------------------
53 | Before starting work on a major feature for yii2-datecontrol, **read the
54 | [documentation](http://demos.krajee.com/datecontrol) first** or you may risk spending a considerable amount of
55 | time on something which the project developers are not interested in bringing into the project.
56 |
57 | ### Submitting a pull request
58 |
59 | We use GitHub's pull request system for submitting patches. Here are some
60 | guidelines to follow when creating the pull request for your fix.
61 |
62 | 1. Make sure to create a ticket for your pull request. This will serve as the
63 | bug ticket, and any discussion about the bug will take place there. Your pull
64 | request will be focused on the specific changes that fix the bug.
65 | 2. Make sure to reference the ticket you are fixing within your pull request.
66 | This will allow us to close off the ticket once we merge the pull request, or
67 | follow up on the ticket if there are any related blocking issues.
68 | 3. Explain why the specific change was made. Not everyone who is reviewing your
69 | pull request will be familiar with the problem it is fixing.
70 | 4. Run your tests first. If your tests aren't passing, the pull request won't
71 | be able to be merged. If you're breaking existing tests, make sure that you
72 | aren't causing any breaking changes.
73 | 5. Only include source changes. While it's not required, only including changes
74 | from the `src` directory will prevent merge conflicts from occuring. Making
75 | this happen can be as a simple as not committing changes from the `dist`
76 | directory.
77 |
78 | By following these steps, you will make it easier for your pull request to be
79 | reviewed and eventually merged.
80 |
81 | Triaging issues and pull requests
82 | ---------------------------------
83 | Anyone can help the project maintainers triage issues and review pull requests.
84 |
85 | ### Handling new issues
86 |
87 | yii2-datecontrol regularly receives new issues which need to be tested and organized.
88 |
89 | When a new issue that comes in that is similar to another existing issue, it
90 | should be checked to make sure it is not a duplicate. Duplicates issues should
91 | be marked by replying to the issue with "Duplicate of #[issue number]" where
92 | `[issue number]` is the url or issue number for the existing issue. This will
93 | allow the project maintainers to quickly close off additional issues and keep
94 | the discussion focused within a single issue.
95 |
96 | If you can test issues that are reported to yii2-datecontrol that contain test cases and
97 | confirm under what conditions bugs happen, that will allow others to identify
98 | what causes a bug quicker.
99 |
100 | ### Reviewing pull requests
101 |
102 | It is very common for pull requests to be opened for issues that contain a clear
103 | solution to the problem. These pull requests should be rigorously reviewed by
104 | the community before being accepted. If you are not sure about a piece of
105 | submitted code, or know of a better way to do something, do not hesitate to make
106 | a comment on the pull request.
107 |
108 | ### Reviving old tickets
109 |
110 | If you come across tickets which have not been updated for a while, you are
111 | encouraged to revive them. While this can be as simple as saying `:+1:`, it is
112 | best if you can include more information on the issue. Common bugs and feature
113 | requests are more likely to be fixed, whether it is by the community or the
114 | developers, so keeping tickets up to date is encouraged.
115 |
116 | Licensing
117 | ---------
118 |
119 | It should also be made clear that **all code contributed to yii2-datecontrol** must be
120 | licensable under the [BSD-3-Clause license][licensing]. Code that cannot be released
121 | under this license **cannot be accepted** into the project.
122 |
123 | [issue-search]: https://github.com/kartik-v/yii2-datecontrol/search?q=&type=Issues
124 | [issue-tracker]: https://github.com/kartik-v/yii2-datecontrol/issues
125 | [licensing]: https://github.com/kartik-v/yii2-datecontrol/blob/master/LICENSE.md
126 | [reporting-bugs]: #reporting-bugs-with-yii2-datecontrol
127 | [requesting-features]: #requesting-features-in-yii2-datecontrol
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Prerequisites
2 |
3 | - [ ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
4 | - [ ] The issue still exists against the latest `master` branch of yii2-datecontrol.
5 | - [ ] This is not an usage question. I confirm having gone through and read the [documentation](http://demos.krajee.com/datecontrol) and [demo](http://demos.krajee.com/datecontrol-demo).
6 | - [ ] This is not a general programming / coding question. (Those should be directed to the [webtips Q & A forum](http://webtips.krajee.com/questions)).
7 | - [ ] I have attempted to find the simplest possible steps to reproduce the issue.
8 | - [ ] I have included a failing test as a pull request (Optional).
9 |
10 | ## Steps to reproduce the issue
11 |
12 | 1.
13 | 2.
14 | 3.
15 |
16 | ## Expected behavior and actual behavior
17 |
18 | When I follow those steps, I see...
19 |
20 | I was expecting...
21 |
22 | ## Environment
23 |
24 | #### Browsers
25 |
26 | - [ ] Google Chrome
27 | - [ ] Mozilla Firefox
28 | - [ ] Internet Explorer
29 | - [ ] Safari
30 |
31 | #### Operating System
32 |
33 | - [ ] Windows
34 | - [ ] Mac OS X
35 | - [ ] Linux
36 | - [ ] Mobile
37 |
38 | #### Libraries
39 |
40 | - jQuery version:
41 | - yii2-datecontrol version:
42 |
43 | ## Isolating the problem
44 |
45 | - [ ] This bug happens [on the demos page](https://demos.krajee.com/datecontrol-demo)
46 | - [ ] The bug happens consistently across all tested browsers
47 | - [ ] This bug happens when using yii2-datecontrol without other plugins.
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Scope
2 | This pull request includes a
3 |
4 | - [ ] Bug fix
5 | - [ ] New feature
6 | - [ ] Translation
7 |
8 | ## Changes
9 | The following changes were made (this change is also documented in the [change log](https://github.com/kartik-v/yii2-datecontrol/blob/master/CHANGE.md)):
10 |
11 | -
12 | -
13 | -
14 |
15 | ## Related Issues
16 | If this is related to an existing ticket, include a link to it as well.
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Number of days of inactivity before an issue becomes stale
2 | daysUntilStale: 60
3 | # Number of days of inactivity before a stale issue is closed
4 | daysUntilClose: 7
5 | # Issues with these labels will never be considered stale
6 | exemptLabels:
7 | - bug
8 | - enhancement
9 | - pinned
10 | - security
11 | # Label to use when marking an issue as stale
12 | staleLabel: wontfix
13 | # Comment to post when marking an issue as stale. Set to `false` to disable
14 | markComment: >
15 | This issue has been automatically marked as stale because it has not had
16 | recent activity. It will be closed if no further activity occurs. Thank you
17 | for your contributions.
18 | # Comment to post when closing a stale issue. Set to `false` to disable
19 | closeComment: false
--------------------------------------------------------------------------------
/CHANGE.md:
--------------------------------------------------------------------------------
1 | Change Log: `yii2-datecontrol`
2 | ==============================
3 |
4 | ## version 1.9.9
5 |
6 | **Date:** 04-Mar-2022
7 |
8 | - PHP 8.1 enhancements for native functions.
9 |
10 | ## version 1.9.8
11 |
12 | **Date:** 12-Jun-2021
13 |
14 | - (enh #133): Correct conversion for FORMAT_DATE.
15 |
16 | ## version 1.9.7
17 |
18 | **Date:** 23-Sep-2018
19 |
20 | - Move all source code to the `src` directory.
21 | - Enhancements to support Bootstrap v4.x.
22 | - (enh #124): Load settings from request in ParseController.php.
23 | - (bug #121): Add delay before run validate(), while "timepicker" make changes.
24 | - (enh #120): Better post params validation.
25 | - (enh #113): Correct empty value validation.
26 |
27 | ## version 1.9.6
28 |
29 | **Date:** 14-Jan-2017
30 |
31 | - Better configuration for `Module::convertAction`.
32 | - (bug #108): Initialize auto widget options correctly.
33 | - (bug #106): More correct validation for guessing date without ajax conversion.
34 | - (bug #105): Set date control plugin data correctly within widget options.
35 | - (enh #96, #102): Ignore timezone conversion for `DateControl::FORMAT_DATE`.
36 | - (enh #92): Implement following DateControl plugin events that can be listened via jQuery/javascript:
37 | - `beforechange.datecontrol`: will be triggered before an ajax request is sent when changing the date input on client.
38 | - `changesuccess.datecontrol`: will be triggered after successful change of a date on the client(applicable for both ajax or non ajax conversions).
39 | - `changeerror.datecontrol`: will be triggered when the ajax conversion service returns an error status.
40 | - `changecomplete.datecontrol`: will be triggered after completion of an ajax conversion service.
41 | - `changeajaxerror.datecontrol`: will be triggered when any exception or error is thrown during the ajax conversion.
42 | - `afterpaste.datecontrol`: will be triggered when a data is pasted in the date input on the client.
43 |
44 | ## version 1.9.5
45 |
46 | **Date:** 08-Dec-2016
47 |
48 | - Add github contribution and issue/PR logging templates.
49 | - Enhance PHP Documentation for all classes and methods in the extension.
50 | - Add branch alias for dev-master latest release.
51 | - (enh #94): Add paste support for DateControl.
52 | - (bug #103): **BC BREAKING CHANGE**: A new property `widgetOptions` is available. This property will replace the `options` property for the scenario when `autoWidget` or `widgetClass` is set.
53 |
54 | ## version 1.9.4
55 |
56 | **Date:** 30-Jul-2015
57 |
58 | - (enh #69): Better format conversion to reset unprovided fields to the Unix Epoch.
59 | - (bug #68): Better `strpos` validation before ajax conversion.
60 | - (enh #67): Allow multiple locale widgets to be parsed correctly on same page.
61 |
62 | ## version 1.9.3
63 |
64 | **Date:** 19-Jul-2015
65 |
66 | - (enh #66): Localisation format parsing enhancements.
67 | - (enh #59): Enhancements for parsing `yii2-widget-datepicker` better.
68 | - Undo #50 - remove timestamp increase through up/down keys.
69 |
70 | ## version 1.9.2
71 |
72 | **Date:** 02-Jun-2015
73 |
74 | - (enh #58, #60): Fix for triggering asynchronous change event.
75 | - (bug #51): Typo in plugin validation for type.
76 | - (bug #50): Pressing up/down keys to increase/decrease timestamp.
77 |
78 | ## version 1.9.1
79 |
80 | **Date:** 13-Feb-2015
81 |
82 | - Set copyright year to current.
83 | - (bug #43): Allow `datecontrol` module to be used as an embedded submodule.
84 | - (bug #42): Prevent double ajax requests due to plugin internal change events getting triggered.
85 | - (bug #39): Ensure datecontrol is validated on blur.
86 | - (enh #37): Wrong capitalization in 'autoClose'.
87 | - (bug #36): Update default save format settings to php: syntax.
88 |
89 | ## version 1.9.0
90 |
91 | **Date:** 13-Dec-2014
92 |
93 | - (bug #35): Auto convert display and save formats correctly to PHP DateTime format.
94 | - (bug #34): Bug in Module Methods "getDisplayFormat" and "getSaveFormat" converted a correct php format in an incorrect one.
95 | - (bug #34): Locals with short language code like "de" haven't been found because "prefix" was not in string.
96 |
97 | ## version 1.8.0
98 |
99 | **Date:** 04-Dec-2014
100 |
101 | - (enh #33): Auto validate disability using new `disabled` and `readonly` properties in InputWidget
102 | - (enh #31): Enhance widget to use updated plugin registration from Krajee base
103 |
104 | ## version 1.7.0
105 |
106 | **Date:** 17-Nov-2014
107 |
108 | - (enh #28, #29): DateTime createFromFormat wrongly uses current timestamp in time part for bare DATE format.
109 | - (enh #27): Added property for switching between asynchronous or synchronous request via Ajax.
110 |
111 | ## version 1.6.0
112 |
113 | **Date:** 10-Nov-2014
114 |
115 | - Set dependency on Krajee base component.
116 |
117 | ## version 1.5.0
118 |
119 | **Date:** 10-Oct-2014
120 |
121 | - (enh #22): Extension revamped to support PHP and ICU date formats
122 |
123 | ## version 1.4.0
124 |
125 | **Date:** 08-Oct-2014
126 |
127 | - (enh #21): Enhance date format con## version based on new yii helper `FormatConverter` (enrica).
128 |
129 | ## version 1.3.0
130 |
131 | **Date:** 24-Jul-2014
132 |
133 | - (enh #18): Included timezone support for display and save formats (requires `ajaxConversion`).
134 | - PSR 4 alias change
135 |
136 | ## version 1.2.0
137 |
138 | **Date:** 24-Jul-2014
139 |
140 | - (enh #14, #15): Revamped and enhanced datecontrol plugin to work with the [php-date-formatter.js](https://github.com/kartik-v/php-date-formatter) jQuery plugin.
141 | - The extension now has an option to either use `ajaxConversion` OR use client level javascript validation to convert date. Ajax con## version is disabled by default.
142 | - Change and Keydown events revamped. The extension now automatically listens to the UP and DOWN presses for the DatePicker widget.
143 | - Preconfigured locales matching DatePicker. Includes a locales folder for date settings configuration for each language.
144 | - Ability to override locale date settings at runtime for each DateControl widget instance.
145 |
146 | ## version 1.1.0
147 |
148 | **Date:** 26-Jun-2014
149 |
150 | - (enh #12): Updated documentation for new `autoWidgetSettings` as per enh # 9.
151 | - (enh #11): Use date con## version using PHP DateTime instead of Yii formatter
152 | - (bug #10): Fix DatePicker convertFormat to work with DateControl.
153 | - (enh #9): Included `autoWidgetSettings` in module, for configuring global settings for `kartik\widgets` when `autoWidget` is true.
154 | - (enh #9): Defaulting rules vastly enhanced. Included the configurable properties `dateControlDisplay` and `dateControlSave` in
155 | `Yii::$app->params`, which can override the module level `displaySettings` and `saveSettings`.
156 | - (enh #4): Fix documentation to include right namespace for Module.
157 | - (enh #4): Fix documentation to include right namespace for Module.
158 | - (bug #3): Fix AutoWidget Plugin Options using right array merge.
159 |
160 | ## version 1.0.0
161 |
162 | **Date:** 01-Jun-2014
163 | Initial release
164 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 - 2022, Kartik Visweswaran
2 | Krajee.com
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification,
6 | are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above copyright notice, this
12 | list of conditions and the following disclaimer in the documentation and/or
13 | other materials provided with the distribution.
14 |
15 | * Neither the names of Kartik Visweswaran or Krajee nor the names of its
16 | contributors may be used to endorse or promote products derived from
17 | this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | yii2-datecontrol
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | [](https://packagist.org/packages/kartik-v/yii2-datecontrol)
17 | [](https://packagist.org/packages/kartik-v/yii2-datecontrol)
18 | [](https://packagist.org/packages/kartik-v/yii2-datecontrol)
19 | [](https://packagist.org/packages/kartik-v/yii2-datecontrol)
20 | [](https://packagist.org/packages/kartik-v/yii2-datecontrol)
21 | [](https://packagist.org/packages/kartik-v/yii2-datecontrol)
22 |
23 |
24 |
25 | The **Date Control** module allows controlling date formats of attributes separately for View and Model for Yii Framework 2.0. It thus allows an easy way to work with dates when displaying to users in one way (format / timezone) but saving it in the database in another way (format / timezone).
26 |
27 | > Refer [CHANGE LOG](https://github.com/kartik-v/yii2-datecontrol/blob/master/CHANGE.md) for details on changes to various releases.
28 |
29 | > NOTE: Version 1.9.5 has BC breaking changes. A new property `widgetOptions` is available. This property will replace the `options` property for the scenario when `autoWidget` or `widgetClass` is set.
30 |
31 | ## Why Date Control?
32 |
33 | When working with the great Yii Framework, one of the most common observations I had was the need to have a proper control on the date settings. The date settings for each
34 | Yii application, are unique to each application and region. Most Yii developers or users almost always need an option of displaying date and time in ONE specific format,
35 | but save them to database in ANOTHER format. So to summarize, the problem statement was:
36 |
37 | - Lack of a single configuration method to display date & times to user (or VIEW) in ONE format
38 | - Lack of a configuration method to save date & times in database (or MODEL) in ANOTHER format
39 |
40 | Most existing Yii solutions try to overcome the above by setting the format in `model->afterFind`, present in view, then unformat it in `model->setAttribues` or `model->beforeValidate`.
41 | This was still an issue when one had many models and views in the application and changes in development cycle, had to be replicated in many places (more complex scenarios being multi-regional formats).
42 |
43 | This module helps overcome this large gap by addressing all of these at the presentational level. The module enables one to configure the date and time
44 | settings separately for DISPLAY and SAVE. This can be setup either globally or individually at each DateControl widget level. And if this is not useful enough, it
45 | automatically enables any date/time picker widgets to be used in conjunction with this.
46 |
47 | How this magic works, is that the extension just alters this at the presentational layer (VIEW). It automatically sets the base model input to hidden and displays
48 | a mirror input in the display format one has set. Then on each edit of the display input, the extension traps the change event, and overrwrites the hidden base model
49 | input as per the desired save format. The other good thing is, that the extension automatically triggers the javascript change event for the base model input
50 | as well. Thus all client model validations and other jquery events needed by Picker widgets are automatically triggered.
51 |
52 | > NOTE: All date and time formats used across this module follow one standard - i.e. [PHP Date Time format strings](http://php.net/manual/en/function.date.php#refsect1-function.date-parameters). The extension automatically
53 | provides three widgets to display and control the date-time inputs.
54 |
55 | - [\kartik\widgets\DatePicker](http://demos.krajee.com/widget-details/datepicker) or [\kartik\date\DatePicker](http://demos.krajee.com/widget-details/datepicker) if your format type is `date`
56 | - [\kartik\widgets\TimePicker](http://demos.krajee.com/widget-details/timepicker) or [\kartik\time\TimePicker](http://demos.krajee.com/widget-details/timepicker)if your format type is `time`
57 | - [\kartik\widgets\DateTimePicker](http://demos.krajee.com/widget-details/datetimepicker) or [\kartik\time\DateTimePicker](http://demos.krajee.com/widget-details/datetimepicker) if your format type is `datetime`
58 |
59 |
60 | ## Module
61 |
62 | The extension has been created as a module to enable access to global settings for your application. In addition, it allows you to read and format date times
63 | between client and server using PHP DateTime object. The DateControl widget uses ajax processing to convert display (view) format to model (save) format.
64 |
65 | ```php
66 | use kartik\datecontrol\Module;
67 | 'modules' => [
68 | 'datecontrol' => [
69 | 'class' => 'kartik\datecontrol\Module',
70 |
71 | // format settings for displaying each date attribute (ICU format example)
72 | 'displaySettings' => [
73 | Module::FORMAT_DATE => 'dd-MM-yyyy',
74 | Module::FORMAT_TIME => 'HH:mm:ss a',
75 | Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss a',
76 | ],
77 |
78 | // format settings for saving each date attribute (PHP format example)
79 | 'saveSettings' => [
80 | Module::FORMAT_DATE => 'php:U', // saves as unix timestamp
81 | Module::FORMAT_TIME => 'php:H:i:s',
82 | Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
83 | ],
84 |
85 | // set your display timezone
86 | 'displayTimezone' => 'Asia/Kolkata',
87 |
88 | // set your timezone for date saved to db
89 | 'saveTimezone' => 'UTC',
90 |
91 | // automatically use kartik\widgets for each of the above formats
92 | 'autoWidget' => true,
93 |
94 | // use ajax conversion for processing dates from display format to save format.
95 | 'ajaxConversion' => true,
96 |
97 | // default settings for each widget from kartik\widgets used when autoWidget is true
98 | 'autoWidgetSettings' => [
99 | Module::FORMAT_DATE => ['type'=>2, 'pluginOptions'=>['autoclose'=>true]], // example
100 | Module::FORMAT_DATETIME => [], // setup if needed
101 | Module::FORMAT_TIME => [], // setup if needed
102 | ],
103 |
104 | // custom widget settings that will be used to render the date input instead of kartik\widgets,
105 | // this will be used when autoWidget is set to false at module or widget level.
106 | 'widgetSettings' => [
107 | Module::FORMAT_DATE => [
108 | 'class' => 'yii\jui\DatePicker', // example
109 | 'options' => [
110 | 'dateFormat' => 'php:d-M-Y',
111 | 'options' => ['class'=>'form-control'],
112 | ]
113 | ]
114 | ]
115 | // other settings
116 | ]
117 | ];
118 | ```
119 |
120 | ## Params Configuration
121 |
122 | The extension allows configuration of `dateControlDisplay` and `dateControlSave` settings at Yii application params level. The params configuration will override the settings at the module level.
123 | This configuration is useful when one wants to dynamically change these params settings at runtime. The settings can be overridden at DateControl widget level.
124 |
125 | Refer the [defaulting rules documentation](http://demos.krajee.com/datecontrol#defaults) for details.
126 |
127 | ## DateControl
128 |
129 | The main widget for rendering each date control on your views. Many settings will be defaulted from the module setup, but can be overridden
130 | at the widget level. An usage example with `ActiveForm` and using `\kartik\widgets\DateTimePicker` is shown below. Note you can pass date-time
131 | formats as supported by ICU or PHP. To set a PHP date time format - prepend the format string with `php:` as shown below.
132 |
133 | ```php
134 | echo $form->field($model, 'datetime_2')->widget(DateControl::classname(), [
135 | 'displayFormat' => 'php:d-M-Y H:i:s',
136 | 'type'=>DateControl::FORMAT_DATETIME
137 | ]);
138 | ```
139 |
140 | > NOTE: With version v1.2.0 this extension can use the new Krajee jQuery library [php-date-formatter](http://plugins.krajee.com/php-date-formatter) to perform client side date format conversion instead of using ajax, for basic date formats (without timezone).
141 | The extension can thus now easily read date & time stamps consistently in ONE format (PHP DateTime) across the client and server. However, it is recommended to use `ajaxConversion` if you need seamless integration with PHP DateTime functions like timezone support.
142 |
143 | ### Demo
144 | You can see detailed [documentation and usage](http://demos.krajee.com/datecontrol), a [detailed demo](http://demos.krajee.com/datecontrol-demo) and [API Code Documentation](https://docs.krajee.com/kartik-datecontrol-datecontrol) for the extension.
145 |
146 | ## Installation
147 |
148 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
149 |
150 | > Note: Check the [composer.json](https://github.com/kartik-v/yii2-datecontrol/blob/master/composer.json) for this extension's requirements and dependencies.
151 | Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.
152 |
153 | Either run
154 |
155 | ```
156 | $ php composer.phar require kartik-v/yii2-datecontrol "@dev"
157 | ```
158 |
159 | or add
160 |
161 | ```
162 | "kartik-v/yii2-datecontrol": "@dev"
163 | ```
164 |
165 | to the `require` section of your `composer.json` file.
166 |
167 | ## Usage
168 | ```php
169 | use kartik\datecontrol\Module;
170 | use kartik\datecontrol\DateControl;
171 | ```
172 |
173 | ## License
174 |
175 | **yii2-datecontrol** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "kartik-v/yii2-datecontrol",
3 | "description": "Date control module allowing separation of formats for View and Model for Yii Framework 2.0",
4 | "keywords": [
5 | "yii",
6 | "yii2",
7 | "extension",
8 | "date",
9 | "control",
10 | "format"
11 | ],
12 | "homepage": "https://github.com/kartik-v/yii2-datecontrol",
13 | "type": "yii2-extension",
14 | "license": "BSD-3-Clause",
15 | "authors": [
16 | {
17 | "name": "Kartik Visweswaran",
18 | "email": "kartikv2@gmail.com",
19 | "homepage": "http://www.krajee.com/"
20 | }
21 | ],
22 | "require": {
23 | "kartik-v/yii2-krajee-base": ">=3.0.4",
24 | "kartik-v/php-date-formatter": ">1.3"
25 | },
26 | "autoload": {
27 | "psr-4": {
28 | "kartik\\datecontrol\\": "src"
29 | }
30 | },
31 | "extra": {
32 | "branch-alias": {
33 | "dev-master": "1.9.x-dev"
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/DateControl.php:
--------------------------------------------------------------------------------
1 |
6 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
7 | * @version 1.9.9
8 | */
9 |
10 | namespace kartik\datecontrol;
11 |
12 | use DateTime;
13 | use DateTimeZone;
14 | use Exception;
15 | use kartik\base\Config;
16 | use kartik\base\InputWidget;
17 | use kartik\base\Lib;
18 | use yii\base\InvalidConfigException;
19 | use yii\helpers\ArrayHelper;
20 | use yii\helpers\Html;
21 | use yii\helpers\Url;
22 |
23 | /**
24 | * DateControl widget enables you to manage formatting of date/time separately for display (View) and saving to
25 | * database (Model).
26 | *
27 | * For example,
28 | *
29 | * ```php
30 | * use kartik\datecontrol\DateControl;
31 | * // usage of rendering date control widget as an active field within Yii active form
32 | * echo $form->field($model, 'datetime_2')->widget(DateControl::class, [
33 | * 'displayFormat' => 'php:d-M-Y H:i:s',
34 | * 'type' => DateControl::FORMAT_DATETIME
35 | * ]);
36 | * ```
37 | *
38 | * @author Kartik Visweswaran
39 | */
40 | class DateControl extends InputWidget
41 | {
42 | /**
43 | * @var string date only format type.
44 | */
45 | const FORMAT_DATE = 'date';
46 | /**
47 | * @var string time only format type.
48 | */
49 | const FORMAT_TIME = 'time';
50 | /**
51 | * @var string date and time format type.
52 | */
53 | const FORMAT_DATETIME = 'datetime';
54 | /**
55 | * @var array the english date settings.
56 | */
57 | private static $_enSettings = [
58 | 'days' => ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
59 | 'daysShort' => ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
60 | 'months' => [
61 | 'January',
62 | 'February',
63 | 'March',
64 | 'April',
65 | 'May',
66 | 'June',
67 | 'July',
68 | 'August',
69 | 'September',
70 | 'October',
71 | 'November',
72 | 'December',
73 | ],
74 | 'monthsShort' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
75 | 'meridiem' => ['AM', 'PM'],
76 | ];
77 | /**
78 | * @var string data type to use for the displayed date control. One of the FORMAT constants.
79 | */
80 | public $type = self::FORMAT_DATE;
81 |
82 | /**
83 | * @var boolean whether to use ajaxConversion to process date format for the widget.
84 | */
85 | public $ajaxConversion;
86 |
87 | /**
88 | * @var string the format string for displaying the date. If not set, will automatically use the settings from the
89 | * [[Module]] based on the [[type]] property.
90 | */
91 | public $displayFormat;
92 |
93 | /**
94 | * @var string the default format string to be save the date as. If not set, will automatically use the settings
95 | * from the [[Module]].
96 | */
97 | public $saveFormat;
98 |
99 | /**
100 | * @var string the timezone for the displayed date. If not set, no timezone setting will be applied for formatting.
101 | * @see http://php.net/manual/en/timezones.php
102 | */
103 | public $displayTimezone;
104 |
105 | /**
106 | * @var string the timezone for the saved date. If not set, no timezone setting will be applied for formatting.
107 | * @see http://php.net/manual/en/timezones.php
108 | */
109 | public $saveTimezone;
110 |
111 | /**
112 | * @var boolean whether to automatically use \kartik\widgets based on `$type`. Will use these widgets:
113 | *
114 | * - [[\kartik\date\DatePicker]] when [[type]] is set to [[FORMAT_DATE]]
115 | * - [[\kartik\time\TimePicker]] when [[type]] is set to [[FORMAT_TIME]]
116 | * - [[\kartik\datetime\DateTimePicker]] when [[type]] is set to [[FORMAT_DATETIME]]
117 | *
118 | * If this property is not set, this will default to `true.`
119 | */
120 | public $autoWidget;
121 |
122 | /**
123 | * @var string any custom widget class to use. Will only be used if [[autoWidget]] is set to `false`.
124 | */
125 | public $widgetClass;
126 |
127 | /**
128 | * @var array the configuration options for the widget which will be parsed only in one of the following cases:
129 | *
130 | * - when [[autoWidget]] is `true` and this corresponds to widget settings for `DatePicker`, `TimePicker`, or
131 | * `DateTimePicker` based on the [[$type]] setting, OR
132 | * - when [[autoWidget]] is `false` and [[widgetClass]] is set and this allows to set the configuration options for
133 | * the particular widget class.
134 | */
135 | public $widgetOptions = [];
136 |
137 | /**
138 | * @var array the HTML attributes for the display input. This property is applicable and parsed only if
139 | * [[autoWidget]] is `false` and [[widgetClass]] is empty or not set. For a widget, the [[widgetOptions]] must be
140 | * used to configure the widget settings.
141 | */
142 | public $options = [];
143 |
144 | /**
145 | * @var array the HTML attributes for the base model input that will be saved typically to database. The following
146 | * special options are recognized:
147 | * - `type`: _string_, whether to generate a 'hidden' or 'text' input. Defaults to 'hidden'.
148 | * - `label`: _string_, any label to be placed before the input. Will be only displayed if 'type' is 'text'.
149 | */
150 | public $saveOptions = [];
151 |
152 | /**
153 | * @var boolean whether to fire an asynchronous ajax request. Defaults to `true`. You can set this to `false` for
154 | * cases, where you need this to be fired synchronously. For example when using this widget as a filter in
155 | * [[\kartik\grid\GridView]].
156 | */
157 | public $asyncRequest = true;
158 | /**
159 | * @inheritdoc
160 | */
161 | public $pluginName = 'datecontrol';
162 | /**
163 | * @var Module the `datecontrol` module instance.
164 | */
165 | protected $_module;
166 | /**
167 | * @var array the parsed widget class settings for each type (defaults from the module setting if not set).
168 | */
169 | protected $_widgetSettings = [];
170 | /**
171 | * @var boolean whether translation is needed.
172 | */
173 | private $_doTranslate = false;
174 |
175 | /**
176 | * Parses and normalizes a date source and converts it to a [[DateTime]] object by parsing it based on specified
177 | * format.
178 | *
179 | * @param string $source the date source pattern.
180 | * @param string $format the date format.
181 | * @param string $timezone the date timezone.
182 | * @param array|string $settings the locale/language date settings.
183 | *
184 | * @return DateTime
185 | */
186 | public static function getTimestamp($source, $format, $timezone = null, $settings = [])
187 | {
188 | if (!isset($source) || $source === '') {
189 | return null;
190 | }
191 | $source = static::parseLocale($source, $format, $settings);
192 | if (Lib::substr($format, 0, 1) !== '!') {
193 | $format = '!' . $format;
194 | }
195 | if ($timezone != null) {
196 | $timestamp = DateTime::createFromFormat($format, $source, new DateTimeZone($timezone));
197 | } else {
198 | $timestamp = DateTime::createFromFormat($format, $source);
199 | }
200 | return $timestamp;
201 | }
202 |
203 | /**
204 | * Fetches the locale settings file.
205 | *
206 | * @param string $lang the locale/language ISO code.
207 | *
208 | * @return string the locale file name.
209 | */
210 | protected static function getLocaleFile($lang)
211 | {
212 | $s = DIRECTORY_SEPARATOR;
213 | $file = __DIR__ . "{$s}locales{$s}{$lang}{$s}dateSettings.php";
214 | if (!file_exists($file)) {
215 | $langShort = Config::getLang($lang);
216 | $file = __DIR__ . "{$s}locales{$s}{$langShort}{$s}dateSettings.php";
217 | }
218 | return $file;
219 | }
220 |
221 | /**
222 | * Parses locale data and returns an english format.
223 | *
224 | * @param string $source the date source pattern.
225 | * @param string $format the date format.
226 | * @param array|string $settings the locale/language date settings.
227 | *
228 | * @return string the converted date source to english.
229 | */
230 | protected static function parseLocale($source, $format, $settings = [])
231 | {
232 | if (empty($settings)) {
233 | return $source;
234 | }
235 | foreach (self::$_enSettings as $key => $value) {
236 | if (!empty($settings[$key]) && static::checkFormatKey($format, $key)) {
237 | $source = Lib::str_ireplace($settings[$key], $value, $source);
238 | }
239 | }
240 | return $source;
241 | }
242 |
243 | /**
244 | * Checks if the format string contains the relevant date format pattern based on the passed key.
245 | *
246 | * @param string $format the date format string
247 | * @param string $key the key to check
248 | *
249 | * @return boolean
250 | */
251 | protected static function checkFormatKey($format, $key)
252 | {
253 | switch ($key) {
254 | case 'months':
255 | return Lib::strpos($format, 'F') !== false;
256 | case 'monthsShort':
257 | return Lib::strpos($format, 'M') !== false;
258 | case 'days':
259 | return Lib::strpos($format, 'l') !== false;
260 | case 'daysShort':
261 | return Lib::strpos($format, 'D') !== false;
262 | case 'meridiem':
263 | return Lib::stripos($format, 'A') !== false;
264 | default:
265 | return false;
266 | }
267 | }
268 |
269 | /**
270 | * @inheritdoc
271 | */
272 | public function init()
273 | {
274 | $this->initConfig();
275 | if (!isset($this->ajaxConversion)) {
276 | $this->ajaxConversion = $this->_module->ajaxConversion;
277 | }
278 | if (!$this->ajaxConversion && ($this->displayTimezone != null || $this->saveTimezone != null)) {
279 | throw new InvalidConfigException(
280 | "You must set 'ajaxConversion' to 'true' when using time-zones for display or save."
281 | );
282 | }
283 | parent::init();
284 | $this->initLanguage();
285 | $this->setDataVar($this->pluginName);
286 | $this->saveOptions['id'] = $this->options['id'];
287 | $this->options['id'] .= '-disp';
288 | if ($this->isWidget()) {
289 | $this->widgetOptions['options']['id'] = $this->options['id'];
290 | }
291 | $this->_doTranslate = isset($this->language) && $this->language != 'en';
292 | if ($this->autoWidget && !isset($this->_widgetSettings[$this->type]['bsVersion']) && isset($this->bsVersion)) {
293 | $this->_widgetSettings[$this->type]['bsVersion'] = $this->bsVersion;
294 | }
295 | $this->initBsVersion();
296 | if ($this->_doTranslate && $this->autoWidget) {
297 | $this->_widgetSettings[$this->type]['options']['language'] = $this->language;
298 | }
299 | $this->setLocale();
300 | }
301 |
302 | /**
303 | * @inheritdoc
304 | */
305 | public function run()
306 | {
307 | $this->registerAssets();
308 | echo $this->getDisplayInput() . $this->getSaveInput();
309 | parent::run();
310 | }
311 |
312 | /**
313 | * Gets the formatted display date value.
314 | *
315 | * @param string $data the input date data.
316 | *
317 | * @return string
318 | */
319 | public function getDisplayValue($data)
320 | {
321 | $saveDate = $data;
322 | $saveFormat = $this->saveFormat;
323 | $settings = $this->_doTranslate ? ArrayHelper::getValue($this->pluginOptions, 'dateSettings', []) : [];
324 | $date = static::getTimestamp($saveDate, $saveFormat, $this->saveTimezone, $settings);
325 | if ($date && $date instanceof DateTime) {
326 | if ($this->displayTimezone != null) {
327 | $date->setTimezone(new DateTimeZone($this->displayTimezone));
328 | }
329 | if ($this->type === self::FORMAT_DATE) {
330 | $value = date($this->displayFormat, $date->getTimestamp());
331 | } else {
332 | $value = $date->format($this->displayFormat);
333 | }
334 | if ($this->_doTranslate) {
335 | $value = $this->translateDate($value, $this->displayFormat);
336 | }
337 | return $value;
338 | }
339 | return null;
340 | }
341 |
342 | /**
343 | * Initializes widget based on module settings.
344 | *
345 | * @throws InvalidConfigException
346 | */
347 | protected function initConfig()
348 | {
349 | $this->_module = Config::initModule(Module::class);
350 | if (!isset($this->autoWidget)) {
351 | $this->autoWidget = $this->_module->autoWidget;
352 | }
353 | if (!$this->autoWidget && !empty($this->widgetClass) && !class_exists($this->widgetClass)) {
354 | throw new InvalidConfigException("The widgetClass '{$this->widgetClass}' entered is invalid.");
355 | }
356 | if ($this->autoWidget === null) {
357 | $this->autoWidget = true;
358 | }
359 | $this->_widgetSettings = $this->_module->widgetSettings;
360 | if (empty($this->displayFormat)) {
361 | $this->displayFormat = $this->_module->getDisplayFormat($this->type);
362 | } else {
363 | $this->displayFormat = Module::parseFormat($this->displayFormat, $this->type);
364 | }
365 | if (empty($this->saveFormat)) {
366 | $this->saveFormat = $this->_module->getSaveFormat($this->type);
367 | } else {
368 | $this->saveFormat = Module::parseFormat($this->saveFormat, $this->type);
369 | }
370 | if (empty($this->displayTimezone)) {
371 | $this->displayTimezone = $this->_module->getDisplayTimezone();
372 | }
373 | if (empty($this->saveTimezone)) {
374 | $this->saveTimezone = $this->_module->getSaveTimezone();
375 | }
376 | // skip timezone validations when using date only inputs
377 | if ($this->type === self::FORMAT_DATE) {
378 | $this->displayTimezone = $this->saveTimezone = null;
379 | }
380 | if ($this->autoWidget) {
381 | $this->_widgetSettings = [
382 | self::FORMAT_DATE => ['class' => '\kartik\date\DatePicker'],
383 | self::FORMAT_DATETIME => ['class' => '\kartik\datetime\DateTimePicker'],
384 | self::FORMAT_TIME => ['class' => '\kartik\time\TimePicker'],
385 | ];
386 | Config::validateInputWidget(
387 | $this->_widgetSettings[$this->type]['class'],
388 | "for DateControl '{$this->type}' format"
389 | );
390 | foreach ($this->_widgetSettings as $type => $setting) {
391 | $this->_widgetSettings[$type]['options'] = $this->_module->autoWidgetSettings[$type];
392 | $this->_widgetSettings[$type]['disabled'] = $this->disabled;
393 | $this->_widgetSettings[$type]['readonly'] = $this->readonly;
394 | }
395 | }
396 | if (empty($this->widgetClass) && !empty($this->_widgetSettings[$this->type]['class'])) {
397 | $this->widgetClass = $this->_widgetSettings[$this->type]['class'];
398 | }
399 | }
400 |
401 | /**
402 | * Whether a widget is used to render the display.
403 | *
404 | * @return boolean
405 | */
406 | protected function isWidget()
407 | {
408 | return ($this->autoWidget || !empty($this->widgetClass));
409 | }
410 |
411 | /**
412 | * Generates the display input.
413 | *
414 | * @return string
415 | * @throws Exception
416 | */
417 | protected function getDisplayInput()
418 | {
419 | $name = ($this->hasModel() ? $this->attribute : $this->name) . '-' . $this->options['id'];
420 | $value = !isset($this->value) || $this->value === '' ? '' : $this->getDisplayValue($this->value);
421 | if (!$this->isWidget()) {
422 | if (empty($this->options['class'])) {
423 | $this->options['class'] = 'form-control';
424 | }
425 | return Html::textInput($name, $value, $this->options);
426 | }
427 | $opts = $this->widgetOptions;
428 | if (!empty($this->displayFormat) && $this->autoWidget) {
429 | $defaultOptions = Module::defaultWidgetOptions($this->type, $this->displayFormat);
430 | $opts = ArrayHelper::merge($defaultOptions, $opts);
431 | }
432 | if (!empty($this->_widgetSettings[$this->type]['options'])) {
433 | $opts = ArrayHelper::merge(
434 | $this->_widgetSettings[$this->type]['options'], $opts
435 | );
436 | }
437 | unset($opts['model'], $opts['attribute']);
438 | $opts['name'] = $name;
439 | $opts['value'] = $value;
440 | /**
441 | * @var InputWidget $class
442 | */
443 | $class = $this->widgetClass;
444 | if (property_exists($class, 'disabled')) {
445 | $opts['disabled'] = $this->disabled;
446 | }
447 | if (property_exists($class, 'readonly')) {
448 | $opts['readonly'] = $this->readonly;
449 | }
450 | $this->widgetOptions = $opts;
451 | return $class::widget($opts);
452 | }
453 |
454 | /**
455 | * Generates the save input.
456 | *
457 | * @return string
458 | */
459 | protected function getSaveInput()
460 | {
461 | $type = ArrayHelper::remove($this->saveOptions, 'type', 'hidden');
462 | $label = ArrayHelper::remove($this->saveOptions, 'label', '');
463 |
464 | if ($type === 'text') {
465 | $this->saveOptions['tabindex'] = 10000;
466 | return $label . ($this->hasModel() ?
467 | Html::activeTextInput($this->model, $this->attribute, $this->saveOptions) :
468 | Html::textInput($this->name, $this->value, $this->saveOptions));
469 | }
470 | return $this->hasModel() ?
471 | Html::activeHiddenInput($this->model, $this->attribute, $this->saveOptions) :
472 | Html::hiddenInput($this->name, $this->value, $this->saveOptions);
473 | }
474 |
475 | /**
476 | * Translate the date string.
477 | *
478 | * @param string $data the input date data.
479 | * @param string $format the input date format.
480 | *
481 | * @return string the translated date.
482 | */
483 | protected function translateDate($data, $format)
484 | {
485 | $out = $data;
486 | foreach (self::$_enSettings as $key => $value) {
487 | if (static::checkFormatKey($format, $key)) {
488 | $out = $this->translate($out, $key);
489 | }
490 | }
491 | return $out;
492 | }
493 |
494 | /**
495 | * Translate a date pattern based on type.
496 | *
497 | * @param string $string input date string.
498 | * @param string $type the type of date pattern as set in [[$_enSettings]].
499 | *
500 | * @return string the translated string.
501 | */
502 | protected function translate($string, $type)
503 | {
504 | if (empty($this->pluginOptions['dateSettings'][$type])) {
505 | return $string;
506 | }
507 | return Lib::str_ireplace(self::$_enSettings[$type], $this->pluginOptions['dateSettings'][$type], $string);
508 | }
509 |
510 | /**
511 | * Sets the locale using the locales configuration settings.
512 | */
513 | protected function setLocale()
514 | {
515 | if (!$this->_doTranslate || !empty($this->pluginOptions['dateSettings'])) {
516 | return;
517 | }
518 | $file = static::getLocaleFile($this->language);
519 | if (file_exists($file)) {
520 | /** @noinspection PhpIncludeInspection */
521 | $this->pluginOptions['dateSettings'] = require($file);
522 | }
523 | }
524 |
525 | /**
526 | * Registers assets for the [[DateControl]] widget.
527 | */
528 | protected function registerAssets()
529 | {
530 | $view = $this->getView();
531 | DateFormatterAsset::register($view);
532 | DateControlAsset::register($view);
533 | $pluginOptions = empty($this->pluginOptions) ? [] : $this->pluginOptions;
534 | $this->pluginOptions = ArrayHelper::merge(
535 | [
536 | 'idSave' => $this->saveOptions['id'],
537 | 'url' => $this->ajaxConversion ? Url::to($this->_module->convertAction) : '',
538 | 'type' => $this->type,
539 | 'saveFormat' => $this->saveFormat,
540 | 'dispFormat' => $this->displayFormat,
541 | 'saveTimezone' => $this->saveTimezone,
542 | 'dispTimezone' => $this->displayTimezone,
543 | 'asyncRequest' => $this->asyncRequest,
544 | ], $pluginOptions
545 | );
546 | $this->registerPlugin($this->pluginName);
547 | $pluginData = 'data-krajee-' . $this->pluginName;
548 | if (!empty($this->options[$pluginData])) {
549 | $this->widgetOptions['options'][$pluginData] = $this->options[$pluginData];
550 | }
551 | }
552 | }
--------------------------------------------------------------------------------
/src/DateControlAsset.php:
--------------------------------------------------------------------------------
1 |
6 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
7 | * @version 1.9.9
8 | */
9 |
10 | namespace kartik\datecontrol;
11 |
12 | use kartik\base\AssetBundle;
13 |
14 | /**
15 | * Asset bundle for the [[DateControl]] widget.
16 | *
17 | * @author Kartik Visweswaran
18 | * @since 1.0
19 | */
20 | class DateControlAsset extends AssetBundle
21 | {
22 | /**
23 | * @inheritdoc
24 | */
25 | public function init()
26 | {
27 | $this->depends = array_merge($this->depends, ['kartik\datecontrol\DateFormatterAsset']);
28 | $this->setSourcePath(__DIR__ . '/assets');
29 | $this->setupAssets('js', ['js/datecontrol']);
30 | parent::init();
31 | }
32 | }
--------------------------------------------------------------------------------
/src/DateFormatterAsset.php:
--------------------------------------------------------------------------------
1 |
6 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
7 | * @version 1.9.9
8 | */
9 |
10 | namespace kartik\datecontrol;
11 |
12 | use kartik\base\AssetBundle;
13 |
14 | /**
15 | * Asset bundle for the [Krajee PHP Date Formatter](http://plugins.krajee.com/php-date-formatter) extension.
16 | *
17 | * @author Kartik Visweswaran
18 | * @see http://plugins.krajee.com/php-date-formatter
19 | * @since 1.0
20 | */
21 | class DateFormatterAsset extends AssetBundle
22 | {
23 | /**
24 | * @inheritdoc
25 | */
26 | public function init()
27 | {
28 | $this->setSourcePath('@vendor/kartik-v/php-date-formatter');
29 | $this->setupAssets('js', ['js/php-date-formatter']);
30 | parent::init();
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Module.php:
--------------------------------------------------------------------------------
1 |
6 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
7 | * @version 1.9.9
8 | */
9 |
10 | namespace kartik\datecontrol;
11 |
12 | use kartik\base\Lib;
13 | use Yii;
14 | use yii\base\InvalidConfigException;
15 | use yii\base\Module as YiiModule;
16 | use yii\helpers\ArrayHelper;
17 | use yii\helpers\FormatConverter;
18 |
19 | /**
20 | * Date control module for Yii Framework 2.0. This module is necessary to configure and use the [[DateControl]] widget
21 | * in your application.
22 | *
23 | * @author Kartik Visweswaran
24 | * @since 1.0
25 | */
26 | class Module extends YiiModule
27 | {
28 | /**
29 | * @var string current module name.
30 | */
31 | const MODULE = 'datecontrol';
32 | /**
33 | * @var string date only format type.
34 | */
35 | const FORMAT_DATE = 'date';
36 | /**
37 | * @var string time only format type.
38 | */
39 | const FORMAT_TIME = 'time';
40 | /**
41 | * @var string date and time format type.
42 | */
43 | const FORMAT_DATETIME = 'datetime';
44 | /**
45 | * @var array the format settings for displaying each date attribute. An associative array that need to be setup as
46 | * `$type => $format`, where:
47 | *
48 | * `$type`: _string_, one of the `FORMAT` constants, and
49 | * `$format`: _string_, the PHP date/time format.
50 | *
51 | * If this is not set, will automatically use the settings from `Yii::$app->formatter` based on the type setting in
52 | * the [[DateControl]] widget.
53 | */
54 | public $displaySettings = [];
55 |
56 | /**
57 | * @var array the format settings for saving each date attribute. An associative array that need to be setup as
58 | * $type => $format, where:
59 | *
60 | * `$type`: _string_, one of the `FORMAT` constants, and
61 | * `$format`: _string_, the PHP date/time format. Set this to `'U'` to save it in Unix timestamp.
62 | *
63 | * @see [[initSettings()]]
64 | */
65 | public $saveSettings = [];
66 |
67 | /**
68 | * @var string the timezone for the displayed date. If not set, no timezone setting will be applied for formatting.
69 | * @see http://php.net/manual/en/timezones.php
70 | */
71 | public $displayTimezone;
72 |
73 | /**
74 | * @var string the timezone for the saved date. If not set, no timezone setting will be applied for formatting.
75 | * @see http://php.net/manual/en/timezones.php
76 | */
77 | public $saveTimezone;
78 |
79 | /**
80 | * @var boolean whether to automatically use \kartik\widgets based on `$type`. Will use these widgets:
81 | *
82 | * - [[\kartik\date\DatePicker]] when [[type]] is set to [[FORMAT_DATE]]
83 | * - [[\kartik\time\TimePicker]] when [[type]] is set to [[FORMAT_TIME]]
84 | * - [[\kartik\datetime\DateTimePicker]] when [[type]] is set to [[FORMAT_DATETIME]]
85 | *
86 | * If this property is not set, this will default to `true.`
87 | *
88 | * @see [[initSettings()]]
89 | */
90 | public $autoWidget = true;
91 |
92 | /**
93 | * @var array, the auto widget settings that will be used to render the date input when `autoWidget` is set to `true`.
94 | * An associative array that need to be setup as `$type` => `$settings`, where:
95 | *
96 | * - `$type`: _string_, is one of the FORMAT constants, and
97 | * - `$settings`: _array_, the widget settings for the Krajee date/time widgets based on the type.
98 | *
99 | * @see [[initSettings()]]
100 | */
101 | public $autoWidgetSettings = [];
102 |
103 | /**
104 | * @var array the widget settings that will be used to render the date input. An associative array that need
105 | * to be setup as `$type` => `$settings`, where:
106 | *
107 | * - `$type`: _string_, is one of the FORMAT constants, and
108 | * - `$settings`: _array_, which consists of these keys:
109 | * - `class`: _string_, the widget class name for the input widget that will render the date input.
110 | * - `options`: _array_, the HTML attributes for the input widget
111 | *
112 | * If [[autoWidget]] is true, this will be autogenerated.
113 | *
114 | * @see [[initSettings()]]
115 | */
116 | public $widgetSettings = [];
117 |
118 | /**
119 | * @var string|array the route/action to convert the date as per the [[DateControl::saveFormat]] setting in
120 | * [[DateControl]] widget.
121 | */
122 | public $convertAction = ['/datecontrol/parse/convert'];
123 |
124 | /**
125 | * @var boolean, whether to use ajax based date conversion from display to save formats. If
126 | * set to `false`, the plugin will use php-date-formatter.js to convert to the set formats using
127 | * client side validation.
128 | *
129 | * @see http://plugins.krajee.com/php-date-formatter
130 | */
131 | public $ajaxConversion = true;
132 |
133 | /**
134 | * @inheritdoc
135 | */
136 | public function init()
137 | {
138 | $this->initSettings();
139 | parent::init();
140 | }
141 |
142 | /**
143 | * Initializes module settings.
144 | */
145 | public function initSettings()
146 | {
147 | $this->saveSettings += [
148 | self::FORMAT_DATE => 'php:Y-m-d',
149 | self::FORMAT_TIME => 'php:H:i:s',
150 | self::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
151 | ];
152 | $this->initAutoWidget();
153 | }
154 |
155 | /**
156 | * Initializes the [[autoWidgetSettings]] property defaults.
157 | */
158 | protected function initAutoWidget()
159 | {
160 | $format = $this->getDisplayFormat(self::FORMAT_TIME);
161 |
162 | $settings = [
163 | self::FORMAT_DATE => [
164 | 'convertFormat' => true,
165 | ],
166 | self::FORMAT_DATETIME => [
167 | 'convertFormat' => true,
168 | ],
169 | self::FORMAT_TIME => [
170 | 'pluginOptions' => [
171 | 'showSeconds' => Lib::strpos($format, 's') > 0,
172 | 'showMeridian' => Lib::strpos($format, 'a') > 0 || Lib::strpos($format, 'A') > 0,
173 | ],
174 | ],
175 | ];
176 | $this->autoWidgetSettings = ArrayHelper::merge($settings, $this->autoWidgetSettings);
177 | }
178 |
179 | /**
180 | * Gets the display timezone.
181 | *
182 | * @return string
183 | */
184 | public function getDisplayTimezone()
185 | {
186 | if (!empty(Yii::$app->params['dateControlDisplayTimezone'])) {
187 | return Yii::$app->params['dateControlDisplayTimezone'];
188 | } elseif (!empty($this->displayTimezone)) {
189 | return $this->displayTimezone;
190 | } else {
191 | return null;
192 | }
193 | }
194 |
195 | /**
196 | * Gets the save timezone.
197 | *
198 | * @return string
199 | */
200 | public function getSaveTimezone()
201 | {
202 | if (!empty(Yii::$app->params['dateControlSaveTimezone'])) {
203 | return Yii::$app->params['dateControlSaveTimezone'];
204 | } elseif (!empty($this->saveTimezone)) {
205 | return $this->saveTimezone;
206 | } else {
207 | return null;
208 | }
209 | }
210 |
211 | /**
212 | * Gets the display format for the date type. Derives the format based on the following validation sequence:
213 | *
214 | * - if `dateControlDisplay` is set in `Yii::$app->params`, it will be first used
215 | * - else, the format as set in `displaySettings` will be used from this module
216 | * - else, the format as set in `Yii::$app->formatter` will be used
217 | *
218 | * @param string $type the attribute type whether date, datetime, or time
219 | * @return string
220 | * @throws InvalidConfigException
221 | */
222 | public function getDisplayFormat($type)
223 | {
224 | if (!empty(Yii::$app->params['dateControlDisplay'][$type])) {
225 | $value = Yii::$app->params['dateControlDisplay'][$type];
226 | } elseif (!empty($this->displaySettings[$type])) {
227 | $value = $this->displaySettings[$type];
228 | } else {
229 | $attrib = $type . 'Format';
230 | $value = isset(Yii::$app->formatter->$attrib) ? Yii::$app->formatter->$attrib : '';
231 | }
232 | return self::parseFormat($value, $type);
233 | }
234 |
235 | /**
236 | * Gets the save format for the date type. Derives the format based on the following validation sequence:
237 | *
238 | * - if `dateControlSave` is set in `Yii::$app->params`, it will be first used
239 | * - else, the format as set in `displaySettings` will be used from this module
240 | * - else, the format as set in `Yii::$app->formatter` will be used
241 | *
242 | * @param string $type the attribute type whether date, datetime, or time
243 | * @return string
244 | * @throws InvalidConfigException
245 | */
246 | public function getSaveFormat($type)
247 | {
248 | if (!empty(Yii::$app->params['dateControlSave'][$type])) {
249 | $value = Yii::$app->params['dateControlSave'][$type];
250 | } elseif (!empty($this->saveSettings[$type])) {
251 | $value = $this->saveSettings[$type];
252 | } else {
253 | $attrib = $type . 'Format';
254 | $value = isset(Yii::$app->formatter->$attrib) ? Yii::$app->formatter->$attrib : '';
255 | }
256 | return self::parseFormat($value, $type);
257 | }
258 |
259 | /**
260 | * Parse and return format understood by PHP DateTime.
261 | *
262 | * @param string $format the date format pattern in ICU or PHP format.
263 | * @param string $type the date control format type ([[FORMAT_DATE]], [[FORMAT_DATETIME]], or [[FORMAT_TIME]]).
264 | *
265 | * @return string
266 | * @throws InvalidConfigException
267 | */
268 | public static function parseFormat($format, $type)
269 | {
270 | if (strncmp($format, 'php:', 4) === 0) {
271 | return Lib::substr($format, 4);
272 | } elseif ($format != '') {
273 | return FormatConverter::convertDateIcuToPhp($format, $type);
274 | } else {
275 | throw new InvalidConfigException("Error parsing '{$type}' format.");
276 | }
277 | }
278 |
279 | /**
280 | * Gets the default options for the Krajee date/time widgets based on `type`.
281 | *
282 | * @param string $type the date control format type ([[FORMAT_DATE]], [[FORMAT_DATETIME]], or [[FORMAT_TIME]]).
283 | * @param string $format the date-time format pattern.
284 | *
285 | * @return array the widget settings.
286 | */
287 | public static function defaultWidgetOptions($type, $format)
288 | {
289 | $options = [];
290 | if (!empty($format) && $type !== self::FORMAT_TIME) {
291 | $options['convertFormat'] = true;
292 | $options['pluginOptions']['format'] = 'php:' . $format;
293 | } elseif (!empty($format) && $type === self::FORMAT_TIME) {
294 | $options['pluginOptions']['showSeconds'] = Lib::strpos($format, 's') > 0;
295 | $options['pluginOptions']['showMeridian'] = Lib::strpos($format, 'a') > 0 || Lib::strpos($format, 'A') > 0;
296 | }
297 | return $options;
298 | }
299 | }
--------------------------------------------------------------------------------
/src/assets/js/datecontrol.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
3 | * @version 1.9.9
4 | *
5 | * Date control validation plugin
6 | *
7 | * Author: Kartik Visweswaran
8 | *
9 | * For more JQuery plugins visit http://plugins.krajee.com
10 | * For more Yii related demos visit http://demos.krajee.com
11 | */
12 | (function ($) {
13 | "use strict";
14 | var NAMESPACE = '.datecontrol',
15 | isEmpty = function (value, trim) {
16 | return value === null || value === undefined || value.length === 0 || (trim && $.trim(value) === '');
17 | },
18 | DateControl = function (element, options) {
19 | var self = this;
20 | self.$element = $(element);
21 | self.init(options);
22 | self.listen();
23 | };
24 |
25 | DateControl.prototype = {
26 | constructor: DateControl,
27 | init: function (options) {
28 | var self = this,
29 | vSettings = isEmpty(options.dateSettings) ? {} : {dateSettings: options.dateSettings};
30 | $.each(options, function (key, value) {
31 | self[key] = value;
32 | });
33 | self.$idSave = $("#" + options.idSave);
34 | self.dateFormatter = window.DateFormatter ? new window.DateFormatter(vSettings) : {};
35 | if (isEmpty(self.dateFormatter)) {
36 | throw "No DateFormatter plugin found. Ensure you have 'php-date-formatter.js' loaded.";
37 | }
38 | self.isChanged = false;
39 | },
40 | raise: function (event, params) {
41 | var self = this, e = $.Event(event + NAMESPACE), $el = self.$element;
42 | if (params !== undefined) {
43 | $el.trigger(e, params);
44 | } else {
45 | $el.trigger(e);
46 | }
47 | },
48 | validate: function () {
49 | var self = this, $el = self.$element, $idSave = self.$idSave, vUrl = self.url,
50 | vType = self.type, vDispFormat = self.dispFormat, vSaveFormat = self.saveFormat,
51 | vDispTimezone = self.dispTimezone, vSaveTimezone = self.saveTimezone,
52 | vAsyncRequest = self.asyncRequest, vFormatter = self.dateFormatter, vSettings;
53 | if (self.isChanged) {
54 | return;
55 | }
56 | self.isChanged = true;
57 | if (isEmpty($el.val())) {
58 | $idSave.val('').trigger('change');
59 | self.raise('changesuccess', [$el.val(), $idSave.val()]);
60 | self.isChanged = false;
61 | } else {
62 | if (isEmpty(vUrl)) {
63 | var vDispDate = vFormatter.parseDate($el.val(), vDispFormat);
64 | if (vDispDate === false || vDispDate === null || String(vDispDate).length === 0) {
65 | vDispDate = vFormatter.guessDate($el.val(), vDispFormat);
66 | $el.val(vFormatter.formatDate(vDispDate, vDispFormat));
67 | }
68 | $idSave.val(vFormatter.formatDate(vDispDate, vSaveFormat)).trigger('change');
69 | self.raise('changesuccess', [$el.val(), $idSave.val()]);
70 | self.isChanged = false;
71 | } else {
72 | vSettings = self.language.substring(0, 2) === 'en' ? [] : self.dateSettings;
73 | $.ajax({
74 | url: vUrl,
75 | type: "post",
76 | dataType: "json",
77 | async: vAsyncRequest,
78 | data: {
79 | displayDate: $el.val(),
80 | type: vType,
81 | dispFormat: vDispFormat,
82 | saveFormat: vSaveFormat,
83 | dispTimezone: vDispTimezone,
84 | saveTimezone: vSaveTimezone,
85 | settings: vSettings
86 | },
87 | beforeSend: function (jqXHR) {
88 | self.raise('beforechange', [$el.val(), $idSave.val(), jqXHR]);
89 | },
90 | success: function (data, textStatus, jqXHR) {
91 | var ev = 'changeerror';
92 | if (data.status === "success") {
93 | $idSave.val(data.output).trigger('change');
94 | ev = 'changesuccess';
95 | }
96 | self.raise(ev, [$el.val(), $idSave.val(), data, textStatus, jqXHR]);
97 | },
98 | complete: function () {
99 | self.isChanged = false;
100 | self.raise('changecomplete', [$el.val(), $idSave.val()]);
101 | },
102 | error: function (jqXHR, textStatus, errorThrown) {
103 | self.isChanged = false;
104 | self.raise('changeajaxerror', [$el.val(), $idSave.val(), jqXHR, textStatus, errorThrown]);
105 | }
106 | });
107 | }
108 | }
109 | },
110 | listen: function () {
111 | var self = this, $el = self.$element;
112 | $el.on('change', function () {
113 | setTimeout(function () {
114 | self.validate();
115 | }, 100);
116 | }).on('paste', function () {
117 | setTimeout(function () {
118 | $el.val($el.val());
119 | self.validate();
120 | self.raise('afterpaste');
121 | }, 100);
122 | });
123 | }
124 | };
125 |
126 | $.fn.datecontrol = function (option) {
127 | var args = Array.apply(null, arguments);
128 | args.shift();
129 | return this.each(function () {
130 | var $this = $(this),
131 | data = $this.data('datecontrol'),
132 | options = typeof option === 'object' && option;
133 | if (!data) {
134 | data = new DateControl(this, $.extend({}, $.fn.datecontrol.defaults, options, $(this).data()));
135 | $this.data('datecontrol', data);
136 | }
137 | if (typeof option === 'string') {
138 | data[option].apply(data, args);
139 | }
140 | });
141 | };
142 |
143 | $.fn.datecontrol.defaults = {
144 | language: 'en',
145 | dateSettings: {
146 | days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
147 | daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
148 | months: [
149 | 'January', 'February', 'March', 'April', 'May', 'June',
150 | 'July', 'August', 'September', 'October', 'November', 'December'
151 | ],
152 | monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
153 | meridiem: ['AM', 'PM']
154 | },
155 | dispTimezone: null,
156 | saveTimezone: null,
157 | asyncRequest: true
158 | };
159 |
160 | $.fn.datecontrol.Constructor = DateControl;
161 | }(window.jQuery));
--------------------------------------------------------------------------------
/src/assets/js/datecontrol.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
3 | * @version 1.9.9
4 | *
5 | * Date control validation plugin
6 | *
7 | * Author: Kartik Visweswaran
8 | *
9 | * For more JQuery plugins visit http://plugins.krajee.com
10 | * For more Yii related demos visit http://demos.krajee.com
11 | */!function(e){"use strict";var t=".datecontrol",a=function(t,a){return null===t||void 0===t||0===t.length||a&&""===e.trim(t)},n=function(t,a){var n=this;n.$element=e(t),n.init(a),n.listen()};n.prototype={constructor:n,init:function(t){var n=this,r=a(t.dateSettings)?{}:{dateSettings:t.dateSettings};if(e.each(t,function(e,t){n[e]=t}),n.$idSave=e("#"+t.idSave),n.dateFormatter=window.DateFormatter?new window.DateFormatter(r):{},a(n.dateFormatter))throw"No DateFormatter plugin found. Ensure you have 'php-date-formatter.js' loaded.";n.isChanged=!1},raise:function(a,n){var r=this,i=e.Event(a+t),s=r.$element;void 0!==n?s.trigger(i,n):s.trigger(i)},validate:function(){var t,n=this,r=n.$element,i=n.$idSave,s=n.url,o=n.type,u=n.dispFormat,l=n.saveFormat,d=n.dispTimezone,c=n.saveTimezone,v=n.asyncRequest,g=n.dateFormatter;if(!n.isChanged)if(n.isChanged=!0,a(r.val()))i.val("").trigger("change"),n.raise("changesuccess",[r.val(),i.val()]),n.isChanged=!1;else if(a(s)){var h=g.parseDate(r.val(),u);h!==!1&&null!==h&&0!==String(h).length||(h=g.guessDate(r.val(),u),r.val(g.formatDate(h,u))),i.val(g.formatDate(h,l)).trigger("change"),n.raise("changesuccess",[r.val(),i.val()]),n.isChanged=!1}else t="en"===n.language.substring(0,2)?[]:n.dateSettings,e.ajax({url:s,type:"post",dataType:"json",async:v,data:{displayDate:r.val(),type:o,dispFormat:u,saveFormat:l,dispTimezone:d,saveTimezone:c,settings:t},beforeSend:function(e){n.raise("beforechange",[r.val(),i.val(),e])},success:function(e,t,a){var s="changeerror";"success"===e.status&&(i.val(e.output).trigger("change"),s="changesuccess"),n.raise(s,[r.val(),i.val(),e,t,a])},complete:function(){n.isChanged=!1,n.raise("changecomplete",[r.val(),i.val()])},error:function(e,t,a){n.isChanged=!1,n.raise("changeajaxerror",[r.val(),i.val(),e,t,a])}})},listen:function(){var e=this,t=e.$element;t.on("change",function(){setTimeout(function(){e.validate()},100)}).on("paste",function(){setTimeout(function(){t.val(t.val()),e.validate(),e.raise("afterpaste")},100)})}},e.fn.datecontrol=function(t){var a=Array.apply(null,arguments);return a.shift(),this.each(function(){var r=e(this),i=r.data("datecontrol"),s="object"==typeof t&&t;i||(i=new n(this,e.extend({},e.fn.datecontrol.defaults,s,e(this).data())),r.data("datecontrol",i)),"string"==typeof t&&i[t].apply(i,a)})},e.fn.datecontrol.defaults={language:"en",dateSettings:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["AM","PM"]},dispTimezone:null,saveTimezone:null,asyncRequest:!0},e.fn.datecontrol.Constructor=n}(window.jQuery);
--------------------------------------------------------------------------------
/src/controllers/ParseController.php:
--------------------------------------------------------------------------------
1 |
6 | * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2022
7 | * @version 1.9.9
8 | */
9 |
10 | namespace kartik\datecontrol\controllers;
11 |
12 | use DateTimeZone;
13 | use Yii;
14 | use yii\web\Controller;
15 | use yii\web\Response;
16 | use kartik\datecontrol\DateControl;
17 |
18 | /**
19 | * ParseController class manages the actions for date conversion via ajax from display to save.
20 | */
21 | class ParseController extends Controller
22 | {
23 | /**
24 | * Convert display date for saving to model.
25 | *
26 | * @return array JSON encoded HTML output
27 | */
28 | public function actionConvert()
29 | {
30 | Yii::$app->response->format = Response::FORMAT_JSON;
31 | $req = Yii::$app->request;
32 | $post = $req->post();
33 | if (!isset($post['displayDate'])) {
34 | return ['status' => 'error', 'output' => 'No display date found'];
35 | }
36 | $saveFormat = $req->post('saveFormat', '');
37 | $saveTimezone = $req->post('saveTimezone', '');
38 | $dispFormat = $req->post('dispFormat', '');
39 | $dispTimezone = $req->post('dispTimezone', '');
40 | $displayDate = $req->post('displayDate', '');
41 | $settings = $req->post('settings', []);
42 | $date = DateControl::getTimestamp($displayDate, $dispFormat, $dispTimezone, $settings);
43 | if (empty($date) || !$date) {
44 | $value = '';
45 | } elseif ($saveTimezone != null) {
46 | $value = $date->setTimezone(new DateTimeZone($saveTimezone))->format($saveFormat);
47 | } else {
48 | $value = $date->format($saveFormat);
49 | }
50 | return ['status' => 'success', 'output' => $value];
51 | }
52 | }
--------------------------------------------------------------------------------
/src/locales/ar/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت", "الأحد"],
8 | 'daysShort' => ["أحد", "اثنين", "ثلاثاء", "أربعاء", "خميس", "جمعة", "سبت", "أحد"],
9 | 'months' => ["يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"],
10 | 'monthsShort' => ["يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/bg/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота", "Неделя"],
8 | 'daysShort' => ["Нед", "Пон", "Вто", "Сря", "Чет", "Пет", "Съб", "Нед"],
9 | 'months' => ["Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"],
10 | 'monthsShort' => ["Ян", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Ное", "Дек"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
--------------------------------------------------------------------------------
/src/locales/ca/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte", "Diumenge"],
8 | 'daysShort' => ["Diu", "Dil", "Dmt", "Dmc", "Dij", "Div", "Dis", "Diu"],
9 | 'months' => ["Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"],
10 | 'monthsShort' => ["Gen", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Des"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/cs/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle"],
8 | 'daysShort' => ["Ned", "Pon", "Úte", "Stř", "Čtv", "Pát", "Sob", "Ned"],
9 | 'months' => ["Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"],
10 | 'monthsShort' => ["Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čnc", "Srp", "Zář", "Říj", "Lis", "Pro"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/cy/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Sul", "Llun", "Mawrth", "Mercher", "Iau", "Gwener", "Sadwrn", "Sul"],
8 | 'daysShort' => ["Sul", "Llu", "Maw", "Mer", "Iau", "Gwe", "Sad", "Sul"],
9 | 'months' => ["Ionawr", "Chewfror", "Mawrth", "Ebrill", "Mai", "Mehefin", "Gorfennaf", "Awst", "Medi", "Hydref", "Tachwedd", "Rhagfyr"],
10 | 'monthsShort' => ["Ion", "Chw", "Maw", "Ebr", "Mai", "Meh", "Gor", "Aws", "Med", "Hyd", "Tach", "Rha"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/da/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"],
8 | 'daysShort' => ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
9 | 'months' => ["Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/de/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
8 | 'daysShort' => ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"],
9 | 'months' => ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
10 | 'monthsShort' => ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
11 | 'meridiem' => ['Vorm.', 'Nachm.']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/el/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο", "Κυριακή"],
8 | 'daysShort' => ["Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ", "Κυρ"],
9 | 'months' => ["Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"],
10 | 'monthsShort' => ["Ιαν", "Φεβ", "Μαρ", "Απρ", "Μάι", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/es/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo"],
8 | 'daysShort' => ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb", "Dom"],
9 | 'months' => ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
10 | 'monthsShort' => ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/et/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Pühapäev", "Esmaspäev", "Teisipäev", "Kolmapäev", "Neljapäev", "Reede", "Laupäev", "Pühapäev"],
8 | 'daysShort' => ["Pühap", "Esmasp", "Teisip", "Kolmap", "Neljap", "Reede", "Laup", "Pühap"],
9 | 'months' => ["Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"],
10 | 'monthsShort' => ["Jaan", "Veebr", "Märts", "Apr", "Mai", "Juuni", "Juuli", "Aug", "Sept", "Okt", "Nov", "Dets"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/fa/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["یکشنبه", "دوشنبه", "سهشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه", "یکشنبه"],
8 | 'daysShort' => ["یک", "دو", "سه", "چهار", "پنج", "جمعه", "شنبه", "یک"],
9 | 'months' => ["ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"],
10 | 'monthsShort' => ["ژان", "فور", "مار", "آور", "مه", "ژون", "ژوی", "اوت", "سپت", "اکت", "نوا", "دسا"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/fi/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["sunnuntai", "maanantai", "tiistai", "keskiviikko", "torstai", "perjantai", "lauantai", "sunnuntai"],
8 | 'daysShort' => ["sun", "maa", "tii", "kes", "tor", "per", "lau", "sun"],
9 | 'months' => ["tammikuu", "helmikuu", "maaliskuu", "huhtikuu", "toukokuu", "kesäkuu", "heinäkuu", "elokuu", "syyskuu", "lokakuu", "marraskuu", "joulukuu"],
10 | 'monthsShort' => ["tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mar", "jou"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/fr/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
8 | 'daysShort' => ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"],
9 | 'months' => ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
10 | 'monthsShort' => ["Jan", "Fév", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Déc"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/gl/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Domingo", "Luns", "Martes", "Mércores", "Xoves", "Venres", "Sábado", "Domingo"],
8 | 'daysShort' => ["Dom", "Lun", "Mar", "Mér", "Xov", "Ven", "Sáb", "Dom"],
9 | 'months' => ["Xaneiro", "Febreiro", "Marzo", "Abril", "Maio", "Xuño", "Xullo", "Agosto", "Setembro", "Outubro", "Novembro", "Decembro"],
10 | 'monthsShort' => ["Xan", "Feb", "Mar", "Abr", "Mai", "Xun", "Xul", "Ago", "Sep", "Out", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/he/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שבת", "ראשון"],
8 | 'daysShort' => ["א", "ב", "ג", "ד", "ה", "ו", "ש", "א"],
9 | 'months' => ["ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"],
10 | 'monthsShort' => ["ינו", "פבר", "מרץ", "אפר", "מאי", "יונ", "יול", "אוג", "ספט", "אוק", "נוב", "דצמ"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/hr/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Nedjelja", "Ponedjelja", "Utorak", "Srijeda", "Četrtak", "Petak", "Subota", "Nedjelja"],
8 | 'daysShort' => ["Ned", "Pon", "Uto", "Srr", "Čet", "Pet", "Sub", "Ned"],
9 | 'months' => ["Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"],
10 | 'monthsShort' => ["Sije", "Velj", "Ožu", "Tra", "Svi", "Lip", "Jul", "Kol", "Ruj", "Lis", "Stu", "Pro"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/hu/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Vasárnap", "Hétfő", "Kedd", "Szerda", "Csütörtök", "Péntek", "Szombat", "Vasárnap"],
8 | 'daysShort' => ["Vas", "Hét", "Ked", "Sze", "Csü", "Pén", "Szo", "Vas"],
9 | 'months' => ["Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Már", "Ápr", "Máj", "Jún", "Júl", "Aug", "Sze", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/id/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu"],
8 | 'daysShort' => ["Mgu", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Mgu"],
9 | 'months' => ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ags", "Sep", "Okt", "Nov", "Des"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/is/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Sunnudagur", "Mánudagur", "Þriðjudagur", "Miðvikudagur", "Fimmtudagur", "Föstudagur", "Laugardagur", "Sunnudagur"],
8 | 'daysShort' => ["Sun", "Mán", "Þri", "Mið", "Fim", "Fös", "Lau", "Sun"],
9 | 'months' => ["Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Maí", "Jún", "Júl", "Ágú", "Sep", "Okt", "Nóv", "Des"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/it/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"],
8 | 'daysShort' => ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"],
9 | 'months' => ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
10 | 'monthsShort' => ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/ja/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜", "日曜"],
8 | 'daysShort' => ["日", "月", "火", "水", "木", "金", "土", "日"],
9 | 'months' => ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
10 | 'monthsShort' => ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/ka/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი", "კვირა"],
8 | 'daysShort' => ["კვი", "ორშ", "სამ", "ოთხ", "ხუთ", "პარ", "შაბ", "კვი"],
9 | 'months' => ["იანვარი", "თებერვალი", "მარტი", "აპრილი", "მაისი", "ივნისი", "ივლისი", "აგვისტო", "სექტემბერი", "ოქტომები", "ნოემბერი", "დეკემბერი"],
10 | 'monthsShort' => ["იან", "თებ", "მარ", "აპრ", "მაი", "ივნ", "ივლ", "აგვ", "სექ", "ოქტ", "ნოე", "დეკ"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/kk/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Жексенбі", "Дүйсенбі", "Сейсенбі", "Сәрсенбі", "Бейсенбі", "Жұма", "Сенбі", "Жексенбі"],
8 | 'daysShort' => ["Жек", "Дүй", "Сей", "Сәр", "Бей", "Жұм", "Сен", "Жек"],
9 | 'months' => ["Қаңтар", "Ақпан", "Наурыз", "Сәуір", "Мамыр", "Маусым", "Шілде", "Тамыз", "Қыркүйек", "Қазан", "Қараша", "Желтоқсан"],
10 | 'monthsShort' => ["Қаң", "Ақп", "Нау", "Сәу", "Мамыр", "Мау", "Шлд", "Тмз", "Қыр", "Қзн", "Қар", "Жел"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/kr/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일", "일요일"],
8 | 'daysShort' => ["일", "월", "화", "수", "목", "금", "토", "일"],
9 | 'months' => ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
10 | 'monthsShort' => ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/lt/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis", "Sekmadienis"],
8 | 'daysShort' => ["S", "Pr", "A", "T", "K", "Pn", "Š", "S"],
9 | 'months' => ["Sausis", "Vasaris", "Kovas", "Balandis", "Gegužė", "Birželis", "Liepa", "Rugpjūtis", "Rugsėjis", "Spalis", "Lapkritis", "Gruodis"],
10 | 'monthsShort' => ["Sau", "Vas", "Kov", "Bal", "Geg", "Bir", "Lie", "Rugp", "Rugs", "Spa", "Lap", "Gru"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/lv/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Svētdiena", "Pirmdiena", "Otrdiena", "Trešdiena", "Ceturtdiena", "Piektdiena", "Sestdiena", "Svētdiena"],
8 | 'daysShort' => ["Sv", "P", "O", "T", "C", "Pk", "S", "Sv"],
9 | 'months' => ["Janvāris", "Februāris", "Marts", "Aprīlis", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Mai", "Jūn", "Jūl", "Aug", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/mk/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Недела", "Понеделник", "Вторник", "Среда", "Четврток", "Петок", "Сабота", "Недела"],
8 | 'daysShort' => ["Нед", "Пон", "Вто", "Сре", "Чет", "Пет", "Саб", "Нед"],
9 | 'months' => ["Јануари", "Февруари", "Март", "Април", "Мај", "Јуни", "Јули", "Август", "Септември", "Октомври", "Ноември", "Декември"],
10 | 'monthsShort' => ["Јан", "Фев", "Мар", "Апр", "Мај", "Јун", "Јул", "Авг", "Сеп", "Окт", "Ное", "Дек"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/ms/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu", "Ahad"],
8 | 'daysShort' => ["Aha", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab", "Aha"],
9 | 'months' => ["Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/nb/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"],
8 | 'daysShort' => ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
9 | 'months' => ["Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/nl-BE/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
8 | 'daysShort' => ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
9 | 'months' => ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/nl/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
8 | 'daysShort' => ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
9 | 'months' => ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/no/dateSettings.php:
--------------------------------------------------------------------------------
1 | ['Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'],
8 | 'daysShort' => ['Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'],
9 | 'months' => ['Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember'],
10 | 'monthsShort' => ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/pl/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela"],
8 | 'daysShort' => ["Nie", "Pn", "Wt", "Śr", "Czw", "Pt", "So", "Nie"],
9 | 'months' => ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"],
10 | 'monthsShort' => ["Sty", "Lu", "Mar", "Kw", "Maj", "Cze", "Lip", "Sie", "Wrz", "Pa", "Lis", "Gru"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/pt-BR/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
8 | 'daysShort' => ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
9 | 'months' => ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
10 | 'monthsShort' => ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/pt/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
8 | 'daysShort' => ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
9 | 'months' => ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
10 | 'monthsShort' => ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/ro/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă", "Duminică"],
8 | 'daysShort' => ["Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sâm", "Dum"],
9 | 'months' => ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"],
10 | 'monthsShort' => ["Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/rs-latin/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Nedelja", "Ponedeljak", "Utorak", "Sreda", "Četvrtak", "Petak", "Subota", "Nedelja"],
8 | 'daysShort' => ["Ned", "Pon", "Uto", "Sre", "Čet", "Pet", "Sub", "Ned"],
9 | 'months' => ["Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/rs/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Недеља", "Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота", "Недеља"],
8 | 'daysShort' => ["Нед", "Пон", "Уто", "Сре", "Чет", "Пет", "Суб", "Нед"],
9 | 'months' => ["Јануар", "Фебруар", "Март", "Април", "Мај", "Јун", "Јул", "Август", "Септембар", "Октобар", "Новембар", "Децембар"],
10 | 'monthsShort' => ["Јан", "Феб", "Мар", "Апр", "Мај", "Јун", "Јул", "Авг", "Сеп", "Окт", "Нов", "Дец"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/ru/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
8 | 'daysShort' => ["Вск", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Вск"],
9 | 'months' => ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
10 | 'monthsShort' => ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/sk/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota", "Nedeľa"],
8 | 'daysShort' => ["Ned", "Pon", "Uto", "Str", "Štv", "Pia", "Sob", "Ned"],
9 | 'months' => ["Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Máj", "Jún", "Júl", "Aug", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/sl/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Nedelja", "Ponedeljek", "Torek", "Sreda", "Četrtek", "Petek", "Sobota", "Nedelja"],
8 | 'daysShort' => ["Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob", "Ned"],
9 | 'months' => ["Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/sq/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["E Diel", "E Hënë", "E martē", "E mërkurë", "E Enjte", "E Premte", "E Shtunë", "E Diel"],
8 | 'daysShort' => ["Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Shtu", "Die"],
9 | 'months' => ["Janar", "Shkurt", "Mars", "Prill", "Maj", "Qershor", "Korrik", "Gusht", "Shtator", "Tetor", "Nëntor", "Dhjetor"],
10 | 'monthsShort' => ["Jan", "Shk", "Mar", "Pri", "Maj", "Qer", "Korr", "Gu", "Sht", "Tet", "Nën", "Dhjet"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/sv/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"],
8 | 'daysShort' => ["Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör", "Sön"],
9 | 'months' => ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
10 | 'monthsShort' => ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/sw/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi", "Jumapili"],
8 | 'daysShort' => ["J2", "J3", "J4", "J5", "Alh", "Ij", "J1", "J2"],
9 | 'months' => ["Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"],
10 | 'monthsShort' => ["Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/th/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์", "อาทิตย์"],
8 | 'daysShort' => ["อา", "จ", "อ", "พ", "พฤ", "ศ", "ส", "อา"],
9 | 'months' => ["มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"],
10 | 'monthsShort' => ["ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/tr/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar"],
8 | 'daysShort' => ["Pz", "Pzt", "Sal", "Çrş", "Prş", "Cu", "Cts", "Pz"],
9 | 'months' => ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
10 | 'monthsShort' => ["Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/ua/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятница", "Субота", "Неділя"],
8 | 'daysShort' => ["Нед", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Нед"],
9 | 'months' => ["Cічень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"],
10 | 'monthsShort' => ["Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Сер", "Вер", "Жов", "Лис", "Гру"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/vi/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy", "Chủ nhật"],
8 | 'daysShort' => ["CN", "Thứ 2", "Thứ 3", "Thứ 4", "Thứ 5", "Thứ 6", "Thứ 7", "CN"],
9 | 'months' => ["Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"],
10 | 'monthsShort' => ["Th1", "Th2", "Th3", "Th4", "Th5", "Th6", "Th7", "Th8", "Th9", "Th10", "Th11", "Th12"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/zh-CN/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8 | 'daysShort' => ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
9 | 'months' => ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
10 | 'monthsShort' => ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------
/src/locales/zh-TW/dateSettings.php:
--------------------------------------------------------------------------------
1 | ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8 | 'daysShort' => ["週日", "週一", "週二", "週三", "週四", "週五", "週六", "週日"],
9 | 'months' => ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
10 | 'monthsShort' => ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11 | 'meridiem' => ['AM', 'PM']
12 | ];
13 | ?>
14 |
--------------------------------------------------------------------------------