Initial commit
This commit is contained in:
+107
@@ -0,0 +1,107 @@
|
||||
# Extension
|
||||
|
||||
The easiest way to extend the default formatter and parser is to use plugins, but if the existing plugins do not meet your requirements, you can extend them yourself.
|
||||
|
||||
## Token
|
||||
|
||||
Tokens in this library have the following rules:
|
||||
|
||||
- All of the characters must be the same alphabet (`A-Z, a-z`).
|
||||
|
||||
```javascript
|
||||
'E' // Good
|
||||
'EE' // Good
|
||||
'EEEEEEEEEE' // Good, but why so long!?
|
||||
'EES' // Not good
|
||||
'???' // Not good
|
||||
```
|
||||
|
||||
- It is case sensitive.
|
||||
|
||||
```javascript
|
||||
'eee' // Good
|
||||
'Eee' // Not good
|
||||
```
|
||||
|
||||
- Only tokens consisting of the following alphabets can be added to the parser.
|
||||
|
||||
```javascript
|
||||
'Y' // Year
|
||||
'M' // Month
|
||||
'D' // Day
|
||||
'H' // 24-hour
|
||||
'A' // AM PM
|
||||
'h' // 12-hour
|
||||
's' // Second
|
||||
'S' // Millisecond
|
||||
'Z' // Timezone offset
|
||||
```
|
||||
|
||||
- Existing tokens cannot be overwritten.
|
||||
|
||||
```javascript
|
||||
'YYY' // This is OK because the same token does not exists.
|
||||
'SSS' // This cannot be added because the exact same token exists.
|
||||
'EEE' // This is OK for the formatter, but cannot be added to the parser.
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1
|
||||
|
||||
Add `E` token to the formatter. This new token will output "decade" like this:
|
||||
|
||||
```javascript
|
||||
const d1 = new Date(2020, 0, 1);
|
||||
const d2 = new Date(2019, 0, 1);
|
||||
|
||||
date.format(d1, '[The year] YYYY [is] E[s].'); // => "The year 2020 is 2020s."
|
||||
date.format(d2, '[The year] YYYY [is] E[s].'); // => "The year 2019 is 2010s."
|
||||
```
|
||||
|
||||
Source code example is here:
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
|
||||
date.extend({
|
||||
formatter: {
|
||||
E: function (d) {
|
||||
return (d.getFullYear() / 10 | 0) * 10;
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Example 2
|
||||
|
||||
Add `MMMMM` token to the parser. This token ignores case:
|
||||
|
||||
```javascript
|
||||
date.parse('Dec 25 2019', 'MMMMM DD YYYY'); // => December 25, 2019
|
||||
date.parse('dec 25 2019', 'MMMMM DD YYYY'); // => December 25, 2019
|
||||
date.parse('DEC 25 2019', 'MMMMM DD YYYY'); // => December 25, 2019
|
||||
```
|
||||
|
||||
Source code example is here:
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
|
||||
date.extend({
|
||||
parser: {
|
||||
MMMMM: function (str) {
|
||||
const mmm = this.res.MMM.map(m => m.toLowerCase());
|
||||
const result = this.find(mmm, str.toLowerCase());
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Extending the parser may be a bit difficult. Refer to the library source code to grasp the default behavior.
|
||||
|
||||
## Caveats
|
||||
|
||||
Note that switching locales or applying plugins after extending the library will be cleared all extensions. In such cases, you need to extend the library again.
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 KNOWLEDGECODE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
# Locale
|
||||
|
||||
By default, `format()` outputs month, day of week, and meridiem (AM / PM) in English, and functions such as `parse()` assume that a passed date time string is in English. Here it describes how to use other languages in these functions.
|
||||
|
||||
## Usage
|
||||
|
||||
- ES Modules:
|
||||
|
||||
```javascript
|
||||
import date from 'date-and-time';
|
||||
import es from 'date-and-time/locale/es';
|
||||
|
||||
date.locale(es); // Spanish
|
||||
date.format(new Date(), 'dddd D MMMM'); // => 'lunes 11 enero
|
||||
```
|
||||
|
||||
- CommonJS:
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
const fr = require('date-and-time/locale/fr');
|
||||
|
||||
date.locale(fr); // French
|
||||
date.format(new Date(), 'dddd D MMMM'); // => 'lundi 11 janvier'
|
||||
```
|
||||
|
||||
- ES Modules for the browser:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import date from '/path/to/date-and-time.es.min.js';
|
||||
import it from '/path/to/date-and-time/locale/it.es.js';
|
||||
|
||||
date.locale(it); // Italian
|
||||
date.format(new Date(), 'dddd D MMMM'); // => 'Lunedì 11 gennaio'
|
||||
</script>
|
||||
```
|
||||
|
||||
- Older browser:
|
||||
|
||||
```html
|
||||
<script src="/path/to/date-and-time.min.js"></script>
|
||||
<script src="/path/to/locale/zh-cn.js"></script>
|
||||
|
||||
<script>
|
||||
date.locale('zh-cn'); // Chinese
|
||||
date.format(new Date(), 'MMMD日dddd'); // => '1月11日星期一'
|
||||
</script>
|
||||
```
|
||||
|
||||
### NOTE
|
||||
|
||||
- If you want to use ES Modules in Node.js without a transpiler, you need to add `"type": "module"` in your `package.json` or change your file extension from `.js` to `.mjs`.
|
||||
- The locale will be actually switched after executing the `locale()`.
|
||||
- You can also change the locale back to English by importing `en` locale:
|
||||
|
||||
```javascript
|
||||
import en from 'date-and-time/locale/en';
|
||||
|
||||
date.locale(en);
|
||||
```
|
||||
|
||||
## Supported locale List
|
||||
|
||||
At this time, it supports the following locales:
|
||||
|
||||
```text
|
||||
Arabic (ar)
|
||||
Azerbaijani (az)
|
||||
Bengali (bn)
|
||||
Burmese (my)
|
||||
Chinese (zh-cn)
|
||||
Chinese (zh-tw)
|
||||
Czech (cs)
|
||||
Danish (dk)
|
||||
Dutch (nl)
|
||||
English (en)
|
||||
French (fr)
|
||||
German (de)
|
||||
Greek (el)
|
||||
Hindi (hi)
|
||||
Hungarian (hu)
|
||||
Indonesian (id)
|
||||
Italian (it)
|
||||
Japanese (ja)
|
||||
Javanese (jv)
|
||||
Kinyarwanda (rw)
|
||||
Korean (ko)
|
||||
Persian (fa)
|
||||
Polish (pl)
|
||||
Portuguese (pt)
|
||||
Punjabi (pa-in)
|
||||
Romanian (ro)
|
||||
Russian (ru)
|
||||
Serbian (sr)
|
||||
Spanish (es)
|
||||
Thai (th)
|
||||
Turkish (tr)
|
||||
Ukrainian (uk)
|
||||
Uzbek (uz)
|
||||
Vietnamese (vi)
|
||||
```
|
||||
+404
@@ -0,0 +1,404 @@
|
||||
# Plugins
|
||||
|
||||
This library is oriented towards minimalism, so it may seem to some developers to be lacking in features. Plugin is the most realistic solution to such dissatisfaction. By importing plugins, you can extend the functionality of this library, mainly a formatter and a parser.
|
||||
|
||||
*The formatter is used in `format()`, etc., the parser is used in `parse()`, `preparse()`, `isValid()`, etc.*
|
||||
|
||||
## Usage
|
||||
|
||||
- ES Modules:
|
||||
|
||||
```javascript
|
||||
import date from 'date-and-time';
|
||||
// Import the plugin named "foobar".
|
||||
import foobar from 'date-and-time/plugin/foobar';
|
||||
|
||||
// Apply the "foobar" to the library.
|
||||
date.plugin(foobar);
|
||||
```
|
||||
|
||||
- CommonJS:
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import the plugin named "foobar".
|
||||
const foobar = require('date-and-time/plugin/foobar');
|
||||
|
||||
// Apply the "foobar" to the library.
|
||||
date.plugin(foobar);
|
||||
```
|
||||
|
||||
- ES Modules for the browser:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import date from '/path/to/date-and-time.es.min.js';
|
||||
// Import the plugin named "foobar".
|
||||
import foobar from '/path/to/date-and-time/plugin/foobar.es.js';
|
||||
|
||||
// Apply the "foobar" to the library.
|
||||
date.plugin(foobar);
|
||||
</script>
|
||||
```
|
||||
|
||||
- Older browser:
|
||||
|
||||
```html
|
||||
<script src="/path/to/date-and-time.min.js"></script>
|
||||
<!-- Import the plugin named "foobar". -->
|
||||
<script src="/path/to/plugin/foobar.js"></script>
|
||||
|
||||
<script>
|
||||
// Apply the "foobar" to the library.
|
||||
date.plugin('foobar');
|
||||
</script>
|
||||
```
|
||||
|
||||
### Note
|
||||
|
||||
- If you want to use ES Modules in Node.js without a transpiler, you need to add `"type": "module"` in your `package.json` or change your file extension from `.js` to `.mjs`.
|
||||
|
||||
## Plugin List
|
||||
|
||||
- [day-of-week](#day-of-week)
|
||||
- It adds *"dummy"* tokens for `day of week` to the parser.
|
||||
|
||||
- [meridiem](#meridiem)
|
||||
- It adds various notations for `AM PM`.
|
||||
|
||||
- [microsecond](#microsecond)
|
||||
- It adds tokens for microsecond to the parser.
|
||||
|
||||
- [ordinal](#ordinal)
|
||||
- It adds ordinal notation of date to the formatter.
|
||||
|
||||
- [timespan](#timespan)
|
||||
- It adds `timeSpan()` function that calculates the difference of two dates to the library.
|
||||
|
||||
- [timezone](#timezone)
|
||||
- It adds `formatTZ()` and `parseTZ()` functions that support `IANA time zone names` to the library.
|
||||
|
||||
- [two-digit-year](#two-digit-year)
|
||||
- It adds two-digit year notation to the parser.
|
||||
|
||||
---
|
||||
|
||||
### day-of-week
|
||||
|
||||
It adds tokens for `day of week` to the parser. Although `day of week` is not significant information for the parser to identify a date, these tokens are sometimes useful. For example, when a string to be parsed contains a day of week, and you just want to skip it.
|
||||
|
||||
**formatter:**
|
||||
|
||||
There is no change.
|
||||
|
||||
**parser:**
|
||||
|
||||
| token | meaning | acceptable examples |
|
||||
|:------|:-----------|:--------------------|
|
||||
| dddd | long | Friday, Sunday |
|
||||
| ddd | short | Fri, Sun |
|
||||
| dd | very short | Fr, Su |
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "day-of-week" plugin as a named "day_of_week".
|
||||
const day_of_week = require('date-and-time/plugin/day-of-week');
|
||||
|
||||
// Apply the "day_of_week" plugin to the library.
|
||||
date.plugin(day_of_week);
|
||||
|
||||
// You can write like this.
|
||||
date.parse('Thursday, March 05, 2020', 'dddd, MMMM, D YYYY');
|
||||
// You can also write like this, but it is not versatile because length of day of week are variant.
|
||||
date.parse('Thursday, March 05, 2020', ' , MMMM, D YYYY');
|
||||
date.parse('Friday, March 06, 2020', ' , MMMM, D YYYY');
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### meridiem
|
||||
|
||||
It adds various notations for AM PM.
|
||||
|
||||
**formatter:**
|
||||
|
||||
| token | meaning | output examples |
|
||||
|:------|:------------------------|:----------------|
|
||||
| AA | uppercase with ellipsis | A.M., P.M. |
|
||||
| a | lowercase | am, pm |
|
||||
| aa | lowercase with ellipsis | a.m., p.m. |
|
||||
|
||||
**parser:**
|
||||
|
||||
| token | meaning | acceptable examples |
|
||||
|:------|:------------------------|:--------------------|
|
||||
| AA | uppercase with ellipsis | A.M., P.M. |
|
||||
| a | lowercase | am, pm |
|
||||
| aa | lowercase with ellipsis | a.m., p.m. |
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "meridiem" plugin.
|
||||
const meridiem = require('date-and-time/plugin/meridiem');
|
||||
|
||||
// Apply "medidiem" plugin to the library.
|
||||
date.plugin(meridiem);
|
||||
|
||||
// This is default behavior of the formatter.
|
||||
date.format(new Date(), 'hh:mm A'); // => '12:34 PM'
|
||||
|
||||
// These are added tokens to the formatter.
|
||||
date.format(new Date(), 'hh:mm AA'); // => '12:34 P.M.'
|
||||
date.format(new Date(), 'hh:mm a'); // => '12:34 pm'
|
||||
date.format(new Date(), 'hh:mm aa'); // => '12:34 p.m.'
|
||||
|
||||
// This is default behavior of the parser.
|
||||
date.parse('12:34 PM', 'hh:mm A'); // => Jan 1 1970 12:34:00
|
||||
|
||||
// These are added tokens to the parser.
|
||||
date.parse('12:34 P.M.', 'hh:mm AA'); // => Jan 1 1970 12:34:00
|
||||
date.parse('12:34 pm', 'hh:mm a'); // => Jan 1 1970 12:34:00
|
||||
date.parse('12:34 p.m.', 'hh:mm aa'); // => Jan 1 1970 12:34:00
|
||||
```
|
||||
|
||||
This plugin has a **breaking change**. In previous versions, the `A` token for the parser could parse various notations for AM PM, but in the new version, it can only parse `AM` and `PM`. For other notations, a dedicated token is now provided for each.
|
||||
|
||||
---
|
||||
|
||||
### microsecond
|
||||
|
||||
It adds tokens for microsecond to the parser. If a time string to be parsed contains microsecond, these tokens are useful. In JS, however, it is not supported microsecond accuracy, a parsed value is rounded to millisecond accuracy.
|
||||
|
||||
**formatter:**
|
||||
|
||||
There is no change.
|
||||
|
||||
**parser:**
|
||||
|
||||
| token | meaning | acceptable examples |
|
||||
|:-------|:----------------|:--------------------|
|
||||
| SSSSSS | high accuracy | 753123, 022113 |
|
||||
| SSSSS | middle accuracy | 75312, 02211 |
|
||||
| SSSS | low accuracy | 7531, 0221 |
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "microsecond" plugin.
|
||||
const microsecond = require('date-and-time/plugin/microsecond');
|
||||
|
||||
// Apply "microsecond" plugin to the library.
|
||||
date.plugin(microsecond);
|
||||
|
||||
// A date object in JavaScript supports `millisecond` (ms) like this:
|
||||
date.parse('12:34:56.123', 'HH:mm:ss.SSS');
|
||||
|
||||
// 4 or more digits number sometimes seen is not `millisecond`, probably `microsecond` (μs):
|
||||
date.parse('12:34:56.123456', 'HH:mm:ss.SSSSSS');
|
||||
|
||||
// 123456µs will be rounded to 123ms.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### ordinal
|
||||
|
||||
It adds `DDD` token that output ordinal notation of date to the formatter.
|
||||
|
||||
**formatter:**
|
||||
|
||||
| token | meaning | output examples |
|
||||
|:------|:-------------------------|:--------------------|
|
||||
| DDD | ordinal notation of date | 1st, 2nd, 3rd, 31th |
|
||||
|
||||
**parser:**
|
||||
|
||||
There is no change.
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "ordinal" plugin.
|
||||
const ordinal = require('date-and-time/plugin/ordinal');
|
||||
|
||||
// Apply "ordinal" plugin to the library.
|
||||
date.plugin(ordinal);
|
||||
|
||||
// These are default behavior of the formatter.
|
||||
date.format(new Date(), 'MMM D YYYY'); // => Jan 1 2019
|
||||
date.format(new Date(), 'MMM DD YYYY'); // => Jan 01 2019
|
||||
|
||||
// `DDD` token outputs ordinal number of date.
|
||||
date.format(new Date(), 'MMM DDD YYYY'); // => Jan 1st 2019
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### timespan
|
||||
|
||||
It adds `timeSpan()` function that calculates the difference of two dates to the library. This function is similar to `subtract()`, the difference is that it can format the calculation results.
|
||||
|
||||
#### timeSpan(date1, date2)
|
||||
|
||||
- @param {**Date**} date1 - a Date object
|
||||
- @param {**Date**} date2 - a Date object
|
||||
- @returns {**Object**} a result object subtracting date2 from date1
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "timespan" plugin.
|
||||
const timespan = require('date-and-time/plugin/timespan');
|
||||
|
||||
// Apply "timespan" plugin to the library.
|
||||
date.plugin(timespan);
|
||||
|
||||
const now = new Date(2020, 2, 5, 1, 2, 3, 4);
|
||||
const new_years_day = new Date(2020, 0, 1);
|
||||
|
||||
date.timeSpan(now, new_years_day).toDays('D HH:mm:ss.SSS'); // => '64 01:02:03.004'
|
||||
date.timeSpan(now, new_years_day).toHours('H [hours] m [minutes] s [seconds]'); // => '1537 hours 2 minutes 3 seconds'
|
||||
date.timeSpan(now, new_years_day).toMinutes('mmmmmmmmmm [minutes]'); // => '0000092222 minutes'
|
||||
```
|
||||
|
||||
Like `subtract()`, `timeSpan()` returns an object with functions like this:
|
||||
|
||||
| function | description |
|
||||
|:---------------|:------------------------|
|
||||
| toDays | Outputs as dates |
|
||||
| toHours | Outputs as hours |
|
||||
| toMinutes | Outputs as minutes |
|
||||
| toSeconds | Outputs as seconds |
|
||||
| toMilliseconds | Outputs as milliseconds |
|
||||
|
||||
In these functions can be available some tokens to format the calculation result. Here are the tokens and their meanings:
|
||||
|
||||
| function | available tokens |
|
||||
|:---------------|:-----------------|
|
||||
| toDays | D, H, m, s, S |
|
||||
| toHours | H, m, s, S |
|
||||
| toMinutes | m, s, S |
|
||||
| toSeconds | s, S |
|
||||
| toMilliseconds | S |
|
||||
|
||||
| token | meaning |
|
||||
|:------|:------------|
|
||||
| D | date |
|
||||
| H | 24-hour |
|
||||
| m | minute |
|
||||
| s | second |
|
||||
| S | millisecond |
|
||||
|
||||
---
|
||||
|
||||
### timezone
|
||||
|
||||
It adds `formatTZ()` and `parseTZ()` functions that support `IANA time zone names` (`America/Los_Angeles`, `Asia/Tokyo`, and so on) to the library.
|
||||
|
||||
#### formatTZ(dateObj, arg[, timeZone])
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
|
||||
- @param {**string**} [timeZone] - output as this time zone
|
||||
- @returns {**string**} a formatted string
|
||||
|
||||
The `formatTZ()` is upward compatible with `format()`. Tokens available here are the same as for the `format()`. If the `timeZone` is omitted, it output the date string with local time zone.
|
||||
|
||||
#### parseTZ(dateString, arg[, timeZone])
|
||||
|
||||
- @param {**string**} dateString - a date string
|
||||
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
|
||||
- @param {**string**} [timeZone] - input as this time zone
|
||||
- @returns {**Date**} a constructed date
|
||||
|
||||
The `parseTZ()` is upward compatible with `parse()`. Tokens available here are the same as for the `parse()`. If the `timeZone` is omitted, the time zone of the date string is assumed to be local time zone.
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "timezone" plugin.
|
||||
const timezone = require('date-and-time/plugin/timezone');
|
||||
|
||||
// Apply "timezone" plugin to the library.
|
||||
date.plugin(timezone);
|
||||
|
||||
const d1 = new Date(Date.UTC(2021, 2, 14, 9, 59, 59, 999)); // 2021-03-14T09:59:59.999Z
|
||||
date.formatTZ(d1, 'MMMM DD YYYY H:mm:ss.SSS [UTC]Z', 'America/Los_Angeles'); // March 14 2021 1:59:59.999 UTC-0800
|
||||
|
||||
const d2 = new Date(Date.UTC(2021, 2, 14, 10, 0, 0, 0)); // 2021-03-14T10:00:00.000Z
|
||||
date.formatTZ(d2, 'MMMM DD YYYY H:mm:ss.SSS [UTC]Z', 'America/Los_Angeles'); // March 14 2021 3:00:00.000 UTC-0700
|
||||
|
||||
// Parses the date string assuming that the time zone is "Pacific/Honolulu" (UTC-1000).
|
||||
date.parseTZ('Sep 25 2021 4:00:00', 'MMM D YYYY H:mm:ss', 'Pacific/Honolulu'); // 2021-09-25T14:00:00.000Z
|
||||
|
||||
// Parses the date string assuming that the time zone is "Europe/London" (UTC+0100).
|
||||
date.parseTZ('Sep 25 2021 4:00:00', 'MMM D YYYY H:mm:ss', 'Europe/London'); // 2021-09-25T03:00:00.000Z
|
||||
```
|
||||
|
||||
#### Caveats
|
||||
|
||||
- This plugin uses the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) object to parse `IANA time zone names`. Note that if you use this plugin in older browsers, this may **NOT** be supported there. At least it does not work in IE.
|
||||
- If you don't need to use `IANA time zone names`, you should not use this plugin for performance reasons. The `format()` and the `parse()` are enough.
|
||||
|
||||
#### Start of DST (Daylight Saving Time)
|
||||
|
||||
For example, in the US, when local standard time is about to reach Sunday, 14 March 2021, `02:00:00` clocks are turned `forward` 1 hour to Sunday, 14 March 2021, `03:00:00` local daylight time instead. Thus, there is no `02:00:00` to `02:59:59` on 14 March 2021. In such edge cases, the `parseTZ()` will parse like this:
|
||||
|
||||
```javascript
|
||||
date.parseTZ('Mar 14 2021 1:59:59', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-03-14T09:59:59Z
|
||||
date.parseTZ('Mar 14 2021 2:00:00', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => NaN
|
||||
date.parseTZ('Mar 14 2021 2:59:59', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => NaN
|
||||
date.parseTZ('Mar 14 2021 3:00:00', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-03-14T10:00:00Z
|
||||
```
|
||||
|
||||
#### End of DST
|
||||
|
||||
Also, when local daylight time is about to reach Sunday, 7 November 2021, `02:00:00` clocks are turned `backward` 1 hour to Sunday, 7 November 2021, `01:00:00` local standard time instead. Thus, `01:00:00` to `01:59:59` on November 7 2021 is repeated twice. Since there are two possible times between them, DST or not, the `parseTZ()` assumes that the time is former to make the result unique:
|
||||
|
||||
```javascript
|
||||
// The parseTZ() assumes that this time is DST.
|
||||
date.parseTZ('Nov 7 2021 1:59:59', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-11-07T08:59:59Z
|
||||
// This time is already PST.
|
||||
date.parseTZ('Nov 7 2021 2:00:00', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-11-07T10:00:00Z
|
||||
```
|
||||
|
||||
At the first example above, if you want the parser to parse the time as PST (Pacific Standard Time), use the `parse()` with a time offset instead:
|
||||
|
||||
```javascript
|
||||
date.parse('Nov 7 2021 1:59:59 -0800', 'MMM D YYYY H:mm:ss Z'); // => 2021-11-07T09:59:59Z
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### two-digit-year
|
||||
|
||||
It adds `YY` token to the parser. This token will convert the year 69 or earlier to 2000s, the year 70 or later to 1900s. In brief:
|
||||
|
||||
| examples | result |
|
||||
|:------------------------|:-------|
|
||||
| 00, 01, 02, ..., 68, 69 | 2000s |
|
||||
| 70, 71, 72, ..., 98, 99 | 1900s |
|
||||
|
||||
**formatter:**
|
||||
|
||||
There is no change.
|
||||
|
||||
**parser:**
|
||||
|
||||
| token | meaning | acceptable examples |
|
||||
|:------|:---------------|:--------------------|
|
||||
| YY | two-digit year | 90, 00, 08, 19 |
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
// Import "two-digit-year" plugin as a named "two_digit_year".
|
||||
const two_digit_year = require('date-and-time/plugin/two-digit-year');
|
||||
|
||||
// This is the default behavior of the parser.
|
||||
date.parse('Dec 25 69', 'MMM D YY'); // => Invalid Date
|
||||
|
||||
// Apply the "two_digit_year" plugin to the library.
|
||||
date.plugin(two_digit_year);
|
||||
|
||||
// The `YY` token convert the year 69 or earlier to 2000s, the year 70 or later to 1900s.
|
||||
date.parse('Dec 25 69', 'MMM D YY'); // => Dec 25 2069
|
||||
date.parse('Dec 25 70', 'MMM D YY'); // => Dec 25 1970
|
||||
```
|
||||
|
||||
This plugin has a **breaking change**. In previous versions, this plugin overrode the default behavior of the `Y` token, but this has been obsolete.
|
||||
+589
@@ -0,0 +1,589 @@
|
||||
# date-and-time
|
||||
|
||||
[](https://circleci.com/gh/knowledgecode/date-and-time)
|
||||
|
||||
This JS library is just a collection of functions for manipulating date and time. It's small, simple, and easy to learn.
|
||||
|
||||
## Why
|
||||
|
||||
Nowadays, JS modules have become huge, complex, and have many dependencies. We think it makes sense to try to keep each module simple and small. Especially for modules that are at the bottom of the dependency chain, such as those dealing with date and time.
|
||||
|
||||
## Features
|
||||
|
||||
- Minimalist. Approximately 2k. (minified and gzipped)
|
||||
- Extensible. Plugin system support.
|
||||
- Multi language support.
|
||||
- Universal / Isomorphic. Works wherever.
|
||||
- Older browser support. Even works on IE6. :)
|
||||
|
||||
## Install
|
||||
|
||||
```shell
|
||||
npm i date-and-time
|
||||
```
|
||||
|
||||
## Recent Changes
|
||||
|
||||
- 2.0.1
|
||||
- Fixed a bug that the timezone plugin does not support changing locales.
|
||||
|
||||
- 2.0.0
|
||||
- Fixed a conflict when importing multiple plugins and locales.
|
||||
- **Breaking Changes!** Due to the above fix, the specifications of plugin, locale, and extension have been changed. The `meridiem` plugin and the `two-digit-year` plugin are now partially incompatible with previous ones. See [here](./PLUGINS.md) for details. Also the `extend()` function has changed. If you are using it, check [here](./EXTEND.md) for any impact. The locales are still compatible.
|
||||
- Added `timezone` plugin. You can now use the IANA timezone name to output a datetime string or input a date object. See [PLUGINS.md](./PLUGINS.md) for details.
|
||||
|
||||
- 1.0.1
|
||||
- Updated dev dependencies to resolve vulnerability.
|
||||
|
||||
## Usage
|
||||
|
||||
- ES Modules:
|
||||
|
||||
```javascript
|
||||
import date from 'date-and-time';
|
||||
```
|
||||
|
||||
- CommonJS:
|
||||
|
||||
```javascript
|
||||
const date = require('date-and-time');
|
||||
```
|
||||
|
||||
- ES Modules for the browser:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import date from '/path/to/date-and-time.es.min.js';
|
||||
</script>
|
||||
```
|
||||
|
||||
- Older browser:
|
||||
|
||||
```html
|
||||
<script src="/path/to/date-and-time.min.js"></script>
|
||||
```
|
||||
|
||||
### Note
|
||||
|
||||
- If you want to use ES Modules in Node.js without a transpiler, you need to add `"type": "module"` in your `package.json` or change your file extension from `.js` to `.mjs`.
|
||||
|
||||
## API
|
||||
|
||||
- [format](#formatdateobj-arg-utc)
|
||||
- Formatting a Date and Time (Date -> String)
|
||||
|
||||
- [parse](#parsedatestring-arg-utc)
|
||||
- Parsing a Date and Time string (String -> Date)
|
||||
|
||||
- [compile](#compileformatstring)
|
||||
- Compiling a format string
|
||||
|
||||
- [preparse](#preparsedatestring-arg)
|
||||
- Pre-parsing a Date and Time string
|
||||
|
||||
- [isValid](#isvalidarg1-arg2)
|
||||
- Validation
|
||||
|
||||
- [transform](#transformdatestring-arg1-arg2-utc)
|
||||
- Transforming a Date and Time string (String -> String)
|
||||
|
||||
- [addYears](#addyearsdateobj-years)
|
||||
- Adding years
|
||||
|
||||
- [addMonths](#addmonthsdateobj-months)
|
||||
- Adding months
|
||||
|
||||
- [addDays](#adddaysdateobj-days)
|
||||
- Adding days
|
||||
|
||||
- [addHours](#addhoursdateobj-hours)
|
||||
- Adding hours
|
||||
|
||||
- [addMinutes](#addminutesdateobj-minutes)
|
||||
- Adding minutes
|
||||
|
||||
- [addSeconds](#addsecondsdateobj-seconds)
|
||||
- Adding seconds
|
||||
|
||||
- [addMilliseconds](#addmillisecondsdateobj-milliseconds)
|
||||
- Adding milliseconds
|
||||
|
||||
- [subtract](#subtractdate1-date2)
|
||||
- Subtracting two dates
|
||||
|
||||
- [isLeapYear](#isleapyeary)
|
||||
- Whether year is leap year
|
||||
|
||||
- [isSameDay](#issamedaydate1-date2)
|
||||
- Comparison of two dates
|
||||
|
||||
- [locale](#localecode-locale)
|
||||
- Changing the locale or defining new locales
|
||||
|
||||
- [extend](#extendextension)
|
||||
- Feature extension
|
||||
|
||||
- [plugin](#pluginname-plugin)
|
||||
- Importing or defining plugins
|
||||
|
||||
### format(dateObj, arg[, utc])
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
|
||||
- @param {**boolean**} [utc] - output as UTC
|
||||
- @returns {**string**} a formatted string
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
date.format(now, 'YYYY/MM/DD HH:mm:ss'); // => '2015/01/02 23:14:05'
|
||||
date.format(now, 'ddd, MMM DD YYYY'); // => 'Fri, Jan 02 2015'
|
||||
date.format(now, 'hh:mm A [GMT]Z'); // => '11:14 PM GMT-0800'
|
||||
date.format(now, 'hh:mm A [GMT]Z', true); // => '07:14 AM GMT+0000'
|
||||
|
||||
const pattern = date.compile('ddd, MMM DD YYYY');
|
||||
date.format(now, pattern); // => 'Fri, Jan 02 2015'
|
||||
```
|
||||
|
||||
Available tokens and their meanings are as follows:
|
||||
|
||||
| token | meaning | examples of output |
|
||||
|:------|:-------------------------------------|:-------------------|
|
||||
| YYYY | four-digit year | 0999, 2015 |
|
||||
| YY | two-digit year | 99, 01, 15 |
|
||||
| Y | four-digit year without zero-padding | 2, 44, 888, 2015 |
|
||||
| MMMM | month name (long) | January, December |
|
||||
| MMM | month name (short) | Jan, Dec |
|
||||
| MM | month with zero-padding | 01, 12 |
|
||||
| M | month | 1, 12 |
|
||||
| DD | date with zero-padding | 02, 31 |
|
||||
| D | date | 2, 31 |
|
||||
| dddd | day of week (long) | Friday, Sunday |
|
||||
| ddd | day of week (short) | Fri, Sun |
|
||||
| dd | day of week (very short) | Fr, Su |
|
||||
| HH | 24-hour with zero-padding | 23, 08 |
|
||||
| H | 24-hour | 23, 8 |
|
||||
| hh | 12-hour with zero-padding | 11, 08 |
|
||||
| h | 12-hour | 11, 8 |
|
||||
| A | meridiem (uppercase) | AM, PM |
|
||||
| mm | minute with zero-padding | 14, 07 |
|
||||
| m | minute | 14, 7 |
|
||||
| ss | second with zero-padding | 05, 10 |
|
||||
| s | second | 5, 10 |
|
||||
| SSS | millisecond (high accuracy) | 753, 022 |
|
||||
| SS | millisecond (middle accuracy) | 75, 02 |
|
||||
| S | millisecond (low accuracy) | 7, 0 |
|
||||
| Z | timezone offset | +0100, -0800 |
|
||||
|
||||
You can also use the following tokens by importing plugins. See [PLUGINS.md](./PLUGINS.md) for details.
|
||||
|
||||
| token | meaning | examples of output |
|
||||
|:------|:-------------------------------------|:-------------------|
|
||||
| DDD | ordinal notation of date | 1st, 2nd, 3rd |
|
||||
| AA | meridiem (uppercase with ellipsis) | A.M., P.M. |
|
||||
| a | meridiem (lowercase) | am, pm |
|
||||
| aa | meridiem (lowercase with ellipsis) | a.m., p.m. |
|
||||
|
||||
#### Note 1. Comments
|
||||
|
||||
String in parenthese `[...]` in the `formatString` will be ignored as comments:
|
||||
|
||||
```javascript
|
||||
date.format(new Date(), 'DD-[MM]-YYYY'); // => '02-MM-2015'
|
||||
date.format(new Date(), '[DD-[MM]-YYYY]'); // => 'DD-[MM]-YYYY'
|
||||
```
|
||||
|
||||
#### Note 2. Output as UTC
|
||||
|
||||
This function usually outputs a local date-time string. Set to true the `utc` option (the 3rd parameter) if you would like to get a UTC date-time string.
|
||||
|
||||
```javascript
|
||||
date.format(new Date(), 'hh:mm A [GMT]Z'); // => '11:14 PM GMT-0800'
|
||||
date.format(new Date(), 'hh:mm A [GMT]Z', true); // => '07:14 AM GMT+0000'
|
||||
```
|
||||
|
||||
#### Note 3. More Tokens
|
||||
|
||||
You can also define your own tokens. See [EXTEND.md](./EXTEND.md) for details.
|
||||
|
||||
### parse(dateString, arg[, utc])
|
||||
|
||||
- @param {**string**} dateString - a date string
|
||||
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
|
||||
- @param {**boolean**} [utc] - input as UTC
|
||||
- @returns {**Date**} a constructed date
|
||||
|
||||
```javascript
|
||||
date.parse('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss'); // => Jan 2 2015 23:14:05 GMT-0800
|
||||
date.parse('02-01-2015', 'DD-MM-YYYY'); // => Jan 2 2015 00:00:00 GMT-0800
|
||||
date.parse('11:14:05 PM', 'hh:mm:ss A'); // => Jan 1 1970 23:14:05 GMT-0800
|
||||
date.parse('11:14:05 PM', 'hh:mm:ss A', true); // => Jan 1 1970 23:14:05 GMT+0000 (Jan 1 1970 15:14:05 GMT-0800)
|
||||
date.parse('23:14:05 GMT+0900', 'HH:mm:ss [GMT]Z'); // => Jan 1 1970 23:14:05 GMT+0900 (Jan 1 1970 06:14:05 GMT-0800)
|
||||
date.parse('Jam 1 2017', 'MMM D YYYY'); // => Invalid Date
|
||||
date.parse('Feb 29 2017', 'MMM D YYYY'); // => Invalid Date
|
||||
```
|
||||
|
||||
Available tokens and their meanings are as follows:
|
||||
|
||||
| token | meaning | examples of acceptable form |
|
||||
|:-------|:-------------------------------------|:----------------------------|
|
||||
| YYYY | four-digit year | 0999, 2015 |
|
||||
| Y | four-digit year without zero-padding | 2, 44, 88, 2015 |
|
||||
| MMMM | month name (long) | January, December |
|
||||
| MMM | month name (short) | Jan, Dec |
|
||||
| MM | month with zero-padding | 01, 12 |
|
||||
| M | month | 1, 12 |
|
||||
| DD | date with zero-padding | 02, 31 |
|
||||
| D | date | 2, 31 |
|
||||
| HH | 24-hour with zero-padding | 23, 08 |
|
||||
| H | 24-hour | 23, 8 |
|
||||
| hh | 12-hour with zero-padding | 11, 08 |
|
||||
| h | 12-hour | 11, 8 |
|
||||
| A | meridiem (uppercase) | AM, PM |
|
||||
| mm | minute with zero-padding | 14, 07 |
|
||||
| m | minute | 14, 7 |
|
||||
| ss | second with zero-padding | 05, 10 |
|
||||
| s | second | 5, 10 |
|
||||
| SSS | millisecond (high accuracy) | 753, 022 |
|
||||
| SS | millisecond (middle accuracy) | 75, 02 |
|
||||
| S | millisecond (low accuracy) | 7, 0 |
|
||||
| Z | timezone offset | +0100, -0800 |
|
||||
|
||||
You can also use the following tokens by importing plugins. See [PLUGINS.md](./PLUGINS.md) for details.
|
||||
|
||||
| token | meaning | examples of acceptable form |
|
||||
|:-------|:-------------------------------------|:----------------------------|
|
||||
| YY | two-digit year | 90, 00, 08, 19 |
|
||||
| AA | meridiem (uppercase with ellipsis) | A.M., P.M. |
|
||||
| a | meridiem (lowercase) | am, pm |
|
||||
| aa | meridiem (lowercase with ellipsis) | a.m., p.m. |
|
||||
| dddd | day of week (long) | Friday, Sunday |
|
||||
| ddd | day of week (short) | Fri, Sun |
|
||||
| dd | day of week (very short) | Fr, Su |
|
||||
| SSSSSS | microsecond (high accuracy) | 123456, 000001 |
|
||||
| SSSSS | microsecond (middle accuracy) | 12345, 00001 |
|
||||
| SSSS | microsecond (low accuracy) | 1234, 0001 |
|
||||
|
||||
#### Note 1. Invalid Date
|
||||
|
||||
If the function fails to parse, it will return `Invalid Date`. Notice that the `Invalid Date` is a Date object, not `NaN` or `null`. You can tell whether the Date object is invalid as follows:
|
||||
|
||||
```javascript
|
||||
const today = date.parse('Jam 1 2017', 'MMM D YYYY');
|
||||
|
||||
if (isNaN(today)) {
|
||||
// Failure
|
||||
}
|
||||
```
|
||||
|
||||
#### Note 2. Input as UTC
|
||||
|
||||
This function usually assumes the `dateString` is a local date-time. Set to true the `utc` option (the 3rd parameter) if it is a UTC date-time.
|
||||
|
||||
```javascript
|
||||
date.parse('11:14:05 PM', 'hh:mm:ss A'); // => Jan 1 1970 23:14:05 GMT-0800
|
||||
date.parse('11:14:05 PM', 'hh:mm:ss A', true); // => Jan 1 1970 23:14:05 GMT+0000 (Jan 1 1970 15:14:05 GMT-0800)
|
||||
```
|
||||
|
||||
#### Note 3. Default Date Time
|
||||
|
||||
Default date is `January 1, 1970`, time is `00:00:00.000`. Values not passed will be complemented with them:
|
||||
|
||||
```javascript
|
||||
date.parse('11:14:05 PM', 'hh:mm:ss A'); // => Jan 1 1970 23:14:05 GMT-0800
|
||||
date.parse('Feb 2000', 'MMM YYYY'); // => Feb 1 2000 00:00:00 GMT-0800
|
||||
```
|
||||
|
||||
#### Note 4. Max Date / Min Date
|
||||
|
||||
Parsable maximum date is `December 31, 9999`, minimum date is `January 1, 0001`.
|
||||
|
||||
```javascript
|
||||
date.parse('Dec 31 9999', 'MMM D YYYY'); // => Dec 31 9999 00:00:00 GMT-0800
|
||||
date.parse('Dec 31 10000', 'MMM D YYYY'); // => Invalid Date
|
||||
|
||||
date.parse('Jan 1 0001', 'MMM D YYYY'); // => Jan 1 0001 00:00:00 GMT-0800
|
||||
date.parse('Jan 1 0000', 'MMM D YYYY'); // => Invalid Date
|
||||
```
|
||||
|
||||
#### Note 5. 12-hour notation and Meridiem
|
||||
|
||||
If use `hh` or `h` (12-hour) token, use together `A` (meridiem) token to get the right value.
|
||||
|
||||
```javascript
|
||||
date.parse('11:14:05', 'hh:mm:ss'); // => Jan 1 1970 11:14:05 GMT-0800
|
||||
date.parse('11:14:05 PM', 'hh:mm:ss A'); // => Jan 1 1970 23:14:05 GMT-0800
|
||||
```
|
||||
|
||||
#### Note 6. Token disablement
|
||||
|
||||
Use square brackets `[]` if a date-time string includes some token characters. Tokens inside square brackets in the `formatString` will be interpreted as normal characters:
|
||||
|
||||
```javascript
|
||||
date.parse('12 hours 34 minutes', 'HH hours mm minutes'); // => Invalid Date
|
||||
date.parse('12 hours 34 minutes', 'HH [hours] mm [minutes]'); // => Jan 1 1970 12:34:00 GMT-0800
|
||||
```
|
||||
|
||||
#### Note 7. Wildcard
|
||||
|
||||
A white space works as a wildcard token. This token is not interpreted into anything. This means it can be ignored a specific variable string. For example, when you would like to ignore a time part from a date string, you can write as follows:
|
||||
|
||||
```javascript
|
||||
// This will be an error.
|
||||
date.parse('2015/01/02 11:14:05', 'YYYY/MM/DD'); // => Invalid Date
|
||||
// Adjust the length of the format string by appending white spaces of the same length as a part to ignore to the end of it.
|
||||
date.parse('2015/01/02 11:14:05', 'YYYY/MM/DD '); // => Jan 2 2015 00:00:00 GMT-0800
|
||||
```
|
||||
|
||||
#### Note 8. Ellipsis
|
||||
|
||||
The parser supports `...` (ellipsis) token. The above example can be also written like this:
|
||||
|
||||
```javascript
|
||||
date.parse('2015/01/02 11:14:05', 'YYYY/MM/DD...'); // => Jan 2 2015 00:00:00 GMT-0800
|
||||
```
|
||||
|
||||
### compile(formatString)
|
||||
|
||||
- @param {**string**} formatString - a format string
|
||||
- @returns {**Array.\<string\>**} a compiled object
|
||||
|
||||
If you are going to execute the `format()`, the `parse()` or the `isValid()` so many times with one string format, recommended to precompile and reuse it for performance.
|
||||
|
||||
```javascript
|
||||
const pattern = date.compile('MMM D YYYY h:m:s A');
|
||||
|
||||
date.parse('Mar 22 2019 2:54:21 PM', pattern);
|
||||
date.parse('Jul 27 2019 4:15:24 AM', pattern);
|
||||
date.parse('Dec 25 2019 3:51:11 AM', pattern);
|
||||
|
||||
date.format(new Date(), pattern); // => Mar 16 2020 6:24:56 PM
|
||||
```
|
||||
|
||||
### preparse(dateString, arg)
|
||||
|
||||
- @param {**string**} dateString - a date string
|
||||
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
|
||||
- @returns {**Object**} a date structure
|
||||
|
||||
This function takes exactly the same parameters with the `parse()`, but returns a date structure as follows unlike that:
|
||||
|
||||
```javascript
|
||||
date.preparse('Fri Jan 2015 02 23:14:05 GMT-0800', ' MMM YYYY DD HH:mm:ss [GMT]Z');
|
||||
|
||||
{
|
||||
Y: 2015, // Year
|
||||
M: 1, // Month
|
||||
D: 2, // Day
|
||||
H: 23, // 24-hour
|
||||
A: 0, // Meridiem
|
||||
h: 0, // 12-hour
|
||||
m: 14, // Minute
|
||||
s: 5, // Second
|
||||
S: 0, // Millisecond
|
||||
Z: 480, // Timsezone offset
|
||||
_index: 33, // Pointer offset
|
||||
_length: 33, // Length of the date string
|
||||
_match: 7 // Token matching count
|
||||
}
|
||||
```
|
||||
|
||||
This date structure provides a parsing result. You will be able to tell from it how the date string was parsed(, or why the parsing was failed).
|
||||
|
||||
### isValid(arg1[, arg2])
|
||||
|
||||
- @param {**Object|string**} arg1 - a date structure or a date string
|
||||
- @param {**string|Array.\<string\>**} [arg2] - a format string or its compiled object
|
||||
- @returns {**boolean**} whether the date string is a valid date
|
||||
|
||||
This function takes either exactly the same parameters with the `parse()` or a date structure which the `preparse()` returns, evaluates the validity of them.
|
||||
|
||||
```javascript
|
||||
date.isValid('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss'); // => true
|
||||
date.isValid('29-02-2015', 'DD-MM-YYYY'); // => false
|
||||
```
|
||||
|
||||
```javascript
|
||||
const result = date.preparse('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss');
|
||||
date.isValid(result); // => true
|
||||
```
|
||||
|
||||
### transform(dateString, arg1, arg2[, utc])
|
||||
|
||||
- @param {**string**} dateString - a date string
|
||||
- @param {**string|Array.\<string\>**} arg1 - a format string or its compiled object
|
||||
- @param {**string|Array.\<string\>**} arg2 - a transformed format string or its compiled object
|
||||
- @param {**boolean**} [utc] - output as UTC
|
||||
- @returns {**string**} a formatted string
|
||||
|
||||
This function transforms the format of a date string. The 2nd parameter, `arg1`, is the format string of it. Available token list is equal to the `parse()`'s. The 3rd parameter, `arg2`, is the transformed format string. Available token list is equal to the `format()`'s.
|
||||
|
||||
```javascript
|
||||
// 3/8/2020 => 8/3/2020
|
||||
date.transform('3/8/2020', 'D/M/YYYY', 'M/D/YYYY');
|
||||
|
||||
// 13:05 => 01:05 PM
|
||||
date.transform('13:05', 'HH:mm', 'hh:mm A');
|
||||
```
|
||||
|
||||
### addYears(dateObj, years)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} years - number of years to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const next_year = date.addYears(now, 1);
|
||||
```
|
||||
|
||||
### addMonths(dateObj, months)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} months - number of months to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const next_month = date.addMonths(now, 1);
|
||||
```
|
||||
|
||||
### addDays(dateObj, days)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} days - number of days to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const yesterday = date.addDays(now, -1);
|
||||
```
|
||||
|
||||
### addHours(dateObj, hours)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} hours - number of hours to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const an_hour_ago = date.addHours(now, -1);
|
||||
```
|
||||
|
||||
### addMinutes(dateObj, minutes)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} minutes - number of minutes to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const two_minutes_later = date.addMinutes(now, 2);
|
||||
```
|
||||
|
||||
### addSeconds(dateObj, seconds)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} seconds - number of seconds to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const three_seconds_ago = date.addSeconds(now, -3);
|
||||
```
|
||||
|
||||
### addMilliseconds(dateObj, milliseconds)
|
||||
|
||||
- @param {**Date**} dateObj - a Date object
|
||||
- @param {**number**} milliseconds - number of milliseconds to add
|
||||
- @returns {**Date**} a date after adding the value
|
||||
|
||||
```javascript
|
||||
const now = new Date();
|
||||
const a_millisecond_later = date.addMilliseconds(now, 1);
|
||||
```
|
||||
|
||||
### subtract(date1, date2)
|
||||
|
||||
- @param {**Date**} date1 - a Date object
|
||||
- @param {**Date**} date2 - a Date object
|
||||
- @returns {**Object**} a result object subtracting date2 from date1
|
||||
|
||||
```javascript
|
||||
const today = new Date(2015, 0, 2);
|
||||
const yesterday = new Date(2015, 0, 1);
|
||||
|
||||
date.subtract(today, yesterday).toDays(); // => 1 = today - yesterday
|
||||
date.subtract(today, yesterday).toHours(); // => 24
|
||||
date.subtract(today, yesterday).toMinutes(); // => 1440
|
||||
date.subtract(today, yesterday).toSeconds(); // => 86400
|
||||
date.subtract(today, yesterday).toMilliseconds(); // => 86400000
|
||||
```
|
||||
|
||||
### isLeapYear(y)
|
||||
|
||||
- @param {**number**} y - year
|
||||
- @returns {**boolean**} whether year is leap year
|
||||
|
||||
```javascript
|
||||
date.isLeapYear(2015); // => false
|
||||
date.isLeapYear(2012); // => true
|
||||
```
|
||||
|
||||
### isSameDay(date1, date2)
|
||||
|
||||
- @param {**Date**} date1 - a Date object
|
||||
- @param {**Date**} date2 - a Date object
|
||||
- @returns {**boolean**} whether the two dates are the same day (time is ignored)
|
||||
|
||||
```javascript
|
||||
const date1 = new Date(2017, 0, 2, 0); // Jan 2 2017 00:00:00
|
||||
const date2 = new Date(2017, 0, 2, 23, 59); // Jan 2 2017 23:59:00
|
||||
const date3 = new Date(2017, 0, 1, 23, 59); // Jan 1 2017 23:59:00
|
||||
date.isSameDay(date1, date2); // => true
|
||||
date.isSameDay(date1, date3); // => false
|
||||
```
|
||||
|
||||
### locale([code[, locale]])
|
||||
|
||||
- @param {**Function|string**} [code] - locale installer | language code
|
||||
- @param {**Object**} [locale] - locale definition
|
||||
- @returns {**string**} current language code
|
||||
|
||||
It returns the current language code if called without any parameters.
|
||||
|
||||
```javascript
|
||||
date.locale(); // => "en"
|
||||
```
|
||||
|
||||
To switch to any other language, call it with a locale installer or a language code.
|
||||
|
||||
```javascript
|
||||
import es from 'date-and-time/locale/es';
|
||||
|
||||
date.locale(es); // Switch to Spanish
|
||||
```
|
||||
|
||||
See [LOCALE.md](./LOCALE.md) for details.
|
||||
|
||||
### extend(extension)
|
||||
|
||||
- @param {**Object**} extension - extension object
|
||||
- @returns {**void**}
|
||||
|
||||
It extends this library. See [EXTEND.md](./EXTEND.md) for details.
|
||||
|
||||
### plugin(name[, plugin])
|
||||
|
||||
- @param {**Function|string**} name - plugin installer | plugin name
|
||||
- @param {**Object**} [plugin] - plugin object
|
||||
- @returns {**void**}
|
||||
|
||||
Plugin is a named extension object. By installing predefined plugins, you can easily extend this library. See [PLUGINS.md](./PLUGINS.md) for details.
|
||||
|
||||
## Browser Support
|
||||
|
||||
Chrome, Firefox, Safari, Edge, and Internet Explorer 6+.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+474
@@ -0,0 +1,474 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.date = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time (c) KNOWLEDGECODE | MIT
|
||||
*/
|
||||
|
||||
var locales = {},
|
||||
plugins = {},
|
||||
lang = 'en',
|
||||
_res = {
|
||||
MMMM: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
dddd: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
ddd: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
||||
dd: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
||||
A: ['AM', 'PM']
|
||||
},
|
||||
_formatter = {
|
||||
YYYY: function (d/*, formatString*/) { return ('000' + d.getFullYear()).slice(-4); },
|
||||
YY: function (d/*, formatString*/) { return ('0' + d.getFullYear()).slice(-2); },
|
||||
Y: function (d/*, formatString*/) { return '' + d.getFullYear(); },
|
||||
MMMM: function (d/*, formatString*/) { return this.res.MMMM[d.getMonth()]; },
|
||||
MMM: function (d/*, formatString*/) { return this.res.MMM[d.getMonth()]; },
|
||||
MM: function (d/*, formatString*/) { return ('0' + (d.getMonth() + 1)).slice(-2); },
|
||||
M: function (d/*, formatString*/) { return '' + (d.getMonth() + 1); },
|
||||
DD: function (d/*, formatString*/) { return ('0' + d.getDate()).slice(-2); },
|
||||
D: function (d/*, formatString*/) { return '' + d.getDate(); },
|
||||
HH: function (d/*, formatString*/) { return ('0' + d.getHours()).slice(-2); },
|
||||
H: function (d/*, formatString*/) { return '' + d.getHours(); },
|
||||
A: function (d/*, formatString*/) { return this.res.A[d.getHours() > 11 | 0]; },
|
||||
hh: function (d/*, formatString*/) { return ('0' + (d.getHours() % 12 || 12)).slice(-2); },
|
||||
h: function (d/*, formatString*/) { return '' + (d.getHours() % 12 || 12); },
|
||||
mm: function (d/*, formatString*/) { return ('0' + d.getMinutes()).slice(-2); },
|
||||
m: function (d/*, formatString*/) { return '' + d.getMinutes(); },
|
||||
ss: function (d/*, formatString*/) { return ('0' + d.getSeconds()).slice(-2); },
|
||||
s: function (d/*, formatString*/) { return '' + d.getSeconds(); },
|
||||
SSS: function (d/*, formatString*/) { return ('00' + d.getMilliseconds()).slice(-3); },
|
||||
SS: function (d/*, formatString*/) { return ('0' + (d.getMilliseconds() / 10 | 0)).slice(-2); },
|
||||
S: function (d/*, formatString*/) { return '' + (d.getMilliseconds() / 100 | 0); },
|
||||
dddd: function (d/*, formatString*/) { return this.res.dddd[d.getDay()]; },
|
||||
ddd: function (d/*, formatString*/) { return this.res.ddd[d.getDay()]; },
|
||||
dd: function (d/*, formatString*/) { return this.res.dd[d.getDay()]; },
|
||||
Z: function (d/*, formatString*/) {
|
||||
var offset = d.getTimezoneOffset() / 0.6 | 0;
|
||||
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - (offset % 100 * 0.4 | 0))).slice(-4);
|
||||
},
|
||||
post: function (str) { return str; },
|
||||
res: _res
|
||||
},
|
||||
_parser = {
|
||||
YYYY: function (str/*, formatString */) { return this.exec(/^\d{4}/, str); },
|
||||
Y: function (str/*, formatString */) { return this.exec(/^\d{1,4}/, str); },
|
||||
MMMM: function (str/*, formatString */) {
|
||||
var result = this.find(this.res.MMMM, str);
|
||||
result.value++;
|
||||
return result;
|
||||
},
|
||||
MMM: function (str/*, formatString */) {
|
||||
var result = this.find(this.res.MMM, str);
|
||||
result.value++;
|
||||
return result;
|
||||
},
|
||||
MM: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
M: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
DD: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
D: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
HH: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
H: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
A: function (str/*, formatString */) { return this.find(this.res.A, str); },
|
||||
hh: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
h: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
mm: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
m: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
ss: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
s: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
SSS: function (str/*, formatString */) { return this.exec(/^\d{1,3}/, str); },
|
||||
SS: function (str/*, formatString */) {
|
||||
var result = this.exec(/^\d\d?/, str);
|
||||
result.value *= 10;
|
||||
return result;
|
||||
},
|
||||
S: function (str/*, formatString */) {
|
||||
var result = this.exec(/^\d/, str);
|
||||
result.value *= 100;
|
||||
return result;
|
||||
},
|
||||
Z: function (str/*, formatString */) {
|
||||
var result = this.exec(/^[\+-]\d{2}[0-5]\d/, str);
|
||||
result.value = (result.value / 100 | 0) * -60 - result.value % 100;
|
||||
return result;
|
||||
},
|
||||
h12: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
|
||||
exec: function (re, str) {
|
||||
var result = (re.exec(str) || [''])[0];
|
||||
return { value: result | 0, length: result.length };
|
||||
},
|
||||
find: function (array, str) {
|
||||
var index = -1, length = 0;
|
||||
|
||||
for (var i = 0, len = array.length, item; i < len; i++) {
|
||||
item = array[i];
|
||||
if (!str.indexOf(item) && item.length > length) {
|
||||
index = i;
|
||||
length = item.length;
|
||||
}
|
||||
}
|
||||
return { value: index, length: length };
|
||||
},
|
||||
pre: function (str) { return str; },
|
||||
res: _res
|
||||
},
|
||||
extend = function (base, props, override, res) {
|
||||
var obj = {}, key;
|
||||
|
||||
for (key in base) {
|
||||
obj[key] = base[key];
|
||||
}
|
||||
for (key in props || {}) {
|
||||
if (!(!!override ^ !!obj[key])) {
|
||||
obj[key] = props[key];
|
||||
}
|
||||
}
|
||||
if (res) {
|
||||
obj.res = res;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
var proto = {
|
||||
_formatter: _formatter,
|
||||
_parser: _parser
|
||||
};
|
||||
|
||||
/**
|
||||
* Compiling a format string
|
||||
* @param {string} formatString - a format string
|
||||
* @returns {Array.<string>} a compiled object
|
||||
*/
|
||||
proto.compile = function (formatString) {
|
||||
var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
|
||||
|
||||
while ((keys = re.exec(formatString))) {
|
||||
pattern[pattern.length] = keys[0];
|
||||
}
|
||||
return pattern;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formatting a Date and Time
|
||||
* @param {Date} dateObj - a Date object
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @param {boolean} [utc] - output as UTC
|
||||
* @returns {string} a formatted string
|
||||
*/
|
||||
proto.format = function (dateObj, arg, utc) {
|
||||
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
|
||||
offset = dateObj.getTimezoneOffset(),
|
||||
d = this.addMinutes(dateObj, utc ? offset : 0),
|
||||
formatter = this._formatter, str = '';
|
||||
|
||||
d.getTimezoneOffset = function () { return utc ? 0 : offset; };
|
||||
for (var i = 1, len = pattern.length, token; i < len; i++) {
|
||||
token = pattern[i];
|
||||
str += formatter[token] ? formatter.post(formatter[token](d, pattern[0])) : token.replace(/\[(.*)]/, '$1');
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Pre-parsing a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @returns {Object} a date structure
|
||||
*/
|
||||
proto.preparse = function (dateString, arg) {
|
||||
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
|
||||
dt = { Y: 1970, M: 1, D: 1, H: 0, A: 0, h: 0, m: 0, s: 0, S: 0, Z: 0, _index: 0, _length: 0, _match: 0 },
|
||||
comment = /\[(.*)]/, parser = this._parser, offset = 0;
|
||||
|
||||
dateString = parser.pre(dateString);
|
||||
for (var i = 1, len = pattern.length, token, result; i < len; i++) {
|
||||
token = pattern[i];
|
||||
if (parser[token]) {
|
||||
result = parser[token](dateString.slice(offset), pattern[0]);
|
||||
if (!result.length) {
|
||||
break;
|
||||
}
|
||||
offset += result.length;
|
||||
dt[result.token || token.charAt(0)] = result.value;
|
||||
dt._match++;
|
||||
} else if (token === dateString.charAt(offset) || token === ' ') {
|
||||
offset++;
|
||||
} else if (comment.test(token) && !dateString.slice(offset).indexOf(comment.exec(token)[1])) {
|
||||
offset += token.length - 2;
|
||||
} else if (token === '...') {
|
||||
offset = dateString.length;
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
dt.H = dt.H || parser.h12(dt.h, dt.A);
|
||||
dt._index = offset;
|
||||
dt._length = dateString.length;
|
||||
return dt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parsing a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @param {boolean} [utc] - input as UTC
|
||||
* @returns {Date} a constructed date
|
||||
*/
|
||||
proto.parse = function (dateString, arg, utc) {
|
||||
var dt = this.preparse(dateString, arg);
|
||||
|
||||
if (this.isValid(dt)) {
|
||||
dt.M -= dt.Y < 100 ? 22801 : 1; // 22801 = 1900 * 12 + 1
|
||||
if (utc || dt.Z) {
|
||||
return new Date(Date.UTC(dt.Y, dt.M, dt.D, dt.H, dt.m + dt.Z, dt.s, dt.S));
|
||||
}
|
||||
return new Date(dt.Y, dt.M, dt.D, dt.H, dt.m, dt.s, dt.S);
|
||||
}
|
||||
return new Date(NaN);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validation
|
||||
* @param {Object|string} arg1 - a date structure or a date string
|
||||
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
|
||||
* @returns {boolean} whether the date string is a valid date
|
||||
*/
|
||||
proto.isValid = function (arg1, arg2) {
|
||||
var dt = typeof arg1 === 'string' ? this.preparse(arg1, arg2) : arg1,
|
||||
last = [31, 28 + this.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
|
||||
|
||||
return !(
|
||||
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
|
||||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
|
||||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
|
||||
dt.Z < -720 || dt.Z > 840
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforming a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg1 - a format string or its compiled object
|
||||
* @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
|
||||
* @param {boolean} [utc] - output as UTC
|
||||
* @returns {string} a formatted string
|
||||
*/
|
||||
proto.transform = function (dateString, arg1, arg2, utc) {
|
||||
return this.format(this.parse(dateString, arg1), arg2, utc);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding years
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} years - number of years to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addYears = function (dateObj, years) {
|
||||
return this.addMonths(dateObj, years * 12);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding months
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} months - number of months to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMonths = function (dateObj, months) {
|
||||
var d = new Date(dateObj.getTime());
|
||||
|
||||
d.setMonth(d.getMonth() + months);
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding days
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} days - number of days to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addDays = function (dateObj, days) {
|
||||
var d = new Date(dateObj.getTime());
|
||||
|
||||
d.setDate(d.getDate() + days);
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding hours
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} hours - number of hours to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addHours = function (dateObj, hours) {
|
||||
return this.addMinutes(dateObj, hours * 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding minutes
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} minutes - number of minutes to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMinutes = function (dateObj, minutes) {
|
||||
return this.addSeconds(dateObj, minutes * 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding seconds
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} seconds - number of seconds to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addSeconds = function (dateObj, seconds) {
|
||||
return this.addMilliseconds(dateObj, seconds * 1000);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding milliseconds
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} milliseconds - number of milliseconds to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMilliseconds = function (dateObj, milliseconds) {
|
||||
return new Date(dateObj.getTime() + milliseconds);
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtracting two dates
|
||||
* @param {Date} date1 - a Date object
|
||||
* @param {Date} date2 - a Date object
|
||||
* @returns {Object} a result object subtracting date2 from date1
|
||||
*/
|
||||
proto.subtract = function (date1, date2) {
|
||||
var delta = date1.getTime() - date2.getTime();
|
||||
|
||||
return {
|
||||
toMilliseconds: function () {
|
||||
return delta;
|
||||
},
|
||||
toSeconds: function () {
|
||||
return delta / 1000;
|
||||
},
|
||||
toMinutes: function () {
|
||||
return delta / 60000;
|
||||
},
|
||||
toHours: function () {
|
||||
return delta / 3600000;
|
||||
},
|
||||
toDays: function () {
|
||||
return delta / 86400000;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether year is leap year
|
||||
* @param {number} y - year
|
||||
* @returns {boolean} whether year is leap year
|
||||
*/
|
||||
proto.isLeapYear = function (y) {
|
||||
return (!(y % 4) && !!(y % 100)) || !(y % 400);
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison of two dates
|
||||
* @param {Date} date1 - a Date object
|
||||
* @param {Date} date2 - a Date object
|
||||
* @returns {boolean} whether the two dates are the same day (time is ignored)
|
||||
*/
|
||||
proto.isSameDay = function (date1, date2) {
|
||||
return date1.toDateString() === date2.toDateString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Defining new locale
|
||||
* @param {string} code - language code
|
||||
* @param {Function} locale - locale installer
|
||||
* @returns {string} current language code
|
||||
*/
|
||||
proto.locale = function (code, locale) {
|
||||
if (!locales[code]) {
|
||||
locales[code] = locale;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Defining new plugin
|
||||
* @param {string} name - plugin name
|
||||
* @param {Function} plugin - plugin installer
|
||||
* @returns {void}
|
||||
*/
|
||||
proto.plugin = function (name, plugin) {
|
||||
if (!plugins[name]) {
|
||||
plugins[name] = plugin;
|
||||
}
|
||||
};
|
||||
|
||||
var localized_proto = extend(proto);
|
||||
var date = extend(proto);
|
||||
|
||||
/**
|
||||
* Changing locale
|
||||
* @param {Function|string} [locale] - locale object | language code
|
||||
* @returns {string} current language code
|
||||
*/
|
||||
date.locale = function (locale) {
|
||||
var install = typeof locale === 'function' ? locale : date.locale[locale];
|
||||
|
||||
if (!install) {
|
||||
return lang;
|
||||
}
|
||||
lang = install(proto);
|
||||
|
||||
var extension = locales[lang] || {};
|
||||
var res = extend(_res, extension.res, true);
|
||||
var formatter = extend(_formatter, extension.formatter, true, res);
|
||||
var parser = extend(_parser, extension.parser, true, res);
|
||||
|
||||
date._formatter = localized_proto._formatter = formatter;
|
||||
date._parser = localized_proto._parser = parser;
|
||||
|
||||
for (var plugin in plugins) {
|
||||
date.extend(plugins[plugin]);
|
||||
}
|
||||
|
||||
return lang;
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature extension
|
||||
* @param {Object} extension - extension object
|
||||
* @returns {void}
|
||||
*/
|
||||
date.extend = function (extension) {
|
||||
var res = extend(date._parser.res, extension.res);
|
||||
var extender = extension.extender || {};
|
||||
|
||||
date._formatter = extend(date._formatter, extension.formatter, false, res);
|
||||
date._parser = extend(date._parser, extension.parser, false, res);
|
||||
|
||||
for (var key in extender) {
|
||||
if (!date[key]) {
|
||||
date[key] = extender[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Importing plugin
|
||||
* @param {Function|string} plugin - plugin object | plugin name
|
||||
* @returns {void}
|
||||
*/
|
||||
date.plugin = function (plugin) {
|
||||
var install = typeof plugin === 'function' ? plugin : date.plugin[plugin];
|
||||
|
||||
if (install) {
|
||||
date.extend(plugins[install(proto, localized_proto)] || {});
|
||||
}
|
||||
};
|
||||
|
||||
return date;
|
||||
|
||||
}));
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
date-and-time (c) KNOWLEDGECODE | MIT
|
||||
*/
|
||||
'use strict';(function(n,l){"object"===typeof exports&&"undefined"!==typeof module?module.exports=l():"function"===typeof define&&define.amd?define(l):(n="undefined"!==typeof globalThis?globalThis:n||self,n.date=l())})(this,function(){var n={},l={},q="en",t={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
|
||||
ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},w={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+a.getFullYear()},MMMM:function(a){return this.res.MMMM[a.getMonth()]},MMM:function(a){return this.res.MMM[a.getMonth()]},MM:function(a){return("0"+(a.getMonth()+1)).slice(-2)},M:function(a){return""+(a.getMonth()+1)},DD:function(a){return("0"+a.getDate()).slice(-2)},
|
||||
D:function(a){return""+a.getDate()},HH:function(a){return("0"+a.getHours()).slice(-2)},H:function(a){return""+a.getHours()},A:function(a){return this.res.A[11<a.getHours()|0]},hh:function(a){return("0"+(a.getHours()%12||12)).slice(-2)},h:function(a){return""+(a.getHours()%12||12)},mm:function(a){return("0"+a.getMinutes()).slice(-2)},m:function(a){return""+a.getMinutes()},ss:function(a){return("0"+a.getSeconds()).slice(-2)},s:function(a){return""+a.getSeconds()},SSS:function(a){return("00"+a.getMilliseconds()).slice(-3)},
|
||||
SS:function(a){return("0"+(a.getMilliseconds()/10|0)).slice(-2)},S:function(a){return""+(a.getMilliseconds()/100|0)},dddd:function(a){return this.res.dddd[a.getDay()]},ddd:function(a){return this.res.ddd[a.getDay()]},dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.getTimezoneOffset()/.6|0;return(0<a?"-":"+")+("000"+Math.abs(a-(a%100*.4|0))).slice(-4)},post:function(a){return a},res:t},x={YYYY:function(a){return this.exec(/^\d{4}/,a)},Y:function(a){return this.exec(/^\d{1,4}/,a)},
|
||||
MMMM:function(a){a=this.find(this.res.MMMM,a);a.value++;return a},MMM:function(a){a=this.find(this.res.MMM,a);a.value++;return a},MM:function(a){return this.exec(/^\d\d/,a)},M:function(a){return this.exec(/^\d\d?/,a)},DD:function(a){return this.exec(/^\d\d/,a)},D:function(a){return this.exec(/^\d\d?/,a)},HH:function(a){return this.exec(/^\d\d/,a)},H:function(a){return this.exec(/^\d\d?/,a)},A:function(a){return this.find(this.res.A,a)},hh:function(a){return this.exec(/^\d\d/,a)},h:function(a){return this.exec(/^\d\d?/,
|
||||
a)},mm:function(a){return this.exec(/^\d\d/,a)},m:function(a){return this.exec(/^\d\d?/,a)},ss:function(a){return this.exec(/^\d\d/,a)},s:function(a){return this.exec(/^\d\d?/,a)},SSS:function(a){return this.exec(/^\d{1,3}/,a)},SS:function(a){a=this.exec(/^\d\d?/,a);a.value*=10;return a},S:function(a){a=this.exec(/^\d/,a);a.value*=100;return a},Z:function(a){a=this.exec(/^[\+-]\d{2}[0-5]\d/,a);a.value=-60*(a.value/100|0)-a.value%100;return a},h12:function(a,b){return(12===a?0:a)+12*b},exec:function(a,
|
||||
b){a=(a.exec(b)||[""])[0];return{value:a|0,length:a.length}},find:function(a,b){for(var c=-1,d=0,f=0,e=a.length,k;f<e;f++)k=a[f],!b.indexOf(k)&&k.length>d&&(c=f,d=k.length);return{value:c,length:d}},pre:function(a){return a},res:t},m=function(a,b,c,d){var f={},e;for(e in a)f[e]=a[e];for(e in b||{})!!c^!!f[e]||(f[e]=b[e]);d&&(f.res=d);return f},r={_formatter:w,_parser:x,compile:function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,c,d=[a];c=b.exec(a);)d[d.length]=c[0];return d},
|
||||
format:function(a,b,c){b="string"===typeof b?this.compile(b):b;var d=a.getTimezoneOffset();a=this.addMinutes(a,c?d:0);var f=this._formatter,e="";a.getTimezoneOffset=function(){return c?0:d};for(var k=1,u=b.length,h;k<u;k++)h=b[k],e+=f[h]?f.post(f[h](a,b[0])):h.replace(/\[(.*)]/,"$1");return e},preparse:function(a,b){b="string"===typeof b?this.compile(b):b;var c={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},d=/\[(.*)]/,f=this._parser,e=0;a=f.pre(a);for(var k=1,u=b.length,
|
||||
h,p;k<u;k++)if(h=b[k],f[h]){p=f[h](a.slice(e),b[0]);if(!p.length)break;e+=p.length;c[p.token||h.charAt(0)]=p.value;c._match++}else if(h===a.charAt(e)||" "===h)e++;else if(d.test(h)&&!a.slice(e).indexOf(d.exec(h)[1]))e+=h.length-2;else{"..."===h&&(e=a.length);break}c.H=c.H||f.h12(c.h,c.A);c._index=e;c._length=a.length;return c},parse:function(a,b,c){a=this.preparse(a,b);return this.isValid(a)?(a.M-=100>a.Y?22801:1,c||a.Z?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,
|
||||
a.m,a.s,a.S)):new Date(NaN)},isValid:function(a,b){a="string"===typeof a?this.preparse(a,b):a;b=[31,28+this.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1>a._length||a._index-a._length||1>a._match||1>a.Y||9999<a.Y||1>a.M||12<a.M||1>a.D||a.D>b||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-720>a.Z||840<a.Z)},transform:function(a,b,c,d){return this.format(this.parse(a,b),c,d)},addYears:function(a,b){return this.addMonths(a,12*b)},addMonths:function(a,b){a=
|
||||
new Date(a.getTime());a.setMonth(a.getMonth()+b);return a},addDays:function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a},addHours:function(a,b){return this.addMinutes(a,60*b)},addMinutes:function(a,b){return this.addSeconds(a,60*b)},addSeconds:function(a,b){return this.addMilliseconds(a,1E3*b)},addMilliseconds:function(a,b){return new Date(a.getTime()+b)},subtract:function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/
|
||||
1E3},toMinutes:function(){return c/6E4},toHours:function(){return c/36E5},toDays:function(){return c/864E5}}},isLeapYear:function(a){return!(a%4)&&!!(a%100)||!(a%400)},isSameDay:function(a,b){return a.toDateString()===b.toDateString()},locale:function(a,b){n[a]||(n[a]=b)},plugin:function(a,b){l[a]||(l[a]=b)}},v=m(r),g=m(r);g.locale=function(a){a="function"===typeof a?a:g.locale[a];if(!a)return q;q=a(r);var b=n[q]||{},c=m(t,b.res,!0);a=m(w,b.formatter,!0,c);b=m(x,b.parser,!0,c);g._formatter=v._formatter=
|
||||
a;g._parser=v._parser=b;for(var d in l)g.extend(l[d]);return q};g.extend=function(a){var b=m(g._parser.res,a.res),c=a.extender||{};g._formatter=m(g._formatter,a.formatter,!1,b);g._parser=m(g._parser,a.parser,!1,b);for(var d in c)g[d]||(g[d]=c[d])};g.plugin=function(a){(a="function"===typeof a?a:g.plugin[a])&&g.extend(l[a(r,v)]||{})};return g})
|
||||
+466
@@ -0,0 +1,466 @@
|
||||
/**
|
||||
* @preserve date-and-time (c) KNOWLEDGECODE | MIT
|
||||
*/
|
||||
|
||||
var locales = {},
|
||||
plugins = {},
|
||||
lang = 'en',
|
||||
_res = {
|
||||
MMMM: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
dddd: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
ddd: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
||||
dd: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
||||
A: ['AM', 'PM']
|
||||
},
|
||||
_formatter = {
|
||||
YYYY: function (d/*, formatString*/) { return ('000' + d.getFullYear()).slice(-4); },
|
||||
YY: function (d/*, formatString*/) { return ('0' + d.getFullYear()).slice(-2); },
|
||||
Y: function (d/*, formatString*/) { return '' + d.getFullYear(); },
|
||||
MMMM: function (d/*, formatString*/) { return this.res.MMMM[d.getMonth()]; },
|
||||
MMM: function (d/*, formatString*/) { return this.res.MMM[d.getMonth()]; },
|
||||
MM: function (d/*, formatString*/) { return ('0' + (d.getMonth() + 1)).slice(-2); },
|
||||
M: function (d/*, formatString*/) { return '' + (d.getMonth() + 1); },
|
||||
DD: function (d/*, formatString*/) { return ('0' + d.getDate()).slice(-2); },
|
||||
D: function (d/*, formatString*/) { return '' + d.getDate(); },
|
||||
HH: function (d/*, formatString*/) { return ('0' + d.getHours()).slice(-2); },
|
||||
H: function (d/*, formatString*/) { return '' + d.getHours(); },
|
||||
A: function (d/*, formatString*/) { return this.res.A[d.getHours() > 11 | 0]; },
|
||||
hh: function (d/*, formatString*/) { return ('0' + (d.getHours() % 12 || 12)).slice(-2); },
|
||||
h: function (d/*, formatString*/) { return '' + (d.getHours() % 12 || 12); },
|
||||
mm: function (d/*, formatString*/) { return ('0' + d.getMinutes()).slice(-2); },
|
||||
m: function (d/*, formatString*/) { return '' + d.getMinutes(); },
|
||||
ss: function (d/*, formatString*/) { return ('0' + d.getSeconds()).slice(-2); },
|
||||
s: function (d/*, formatString*/) { return '' + d.getSeconds(); },
|
||||
SSS: function (d/*, formatString*/) { return ('00' + d.getMilliseconds()).slice(-3); },
|
||||
SS: function (d/*, formatString*/) { return ('0' + (d.getMilliseconds() / 10 | 0)).slice(-2); },
|
||||
S: function (d/*, formatString*/) { return '' + (d.getMilliseconds() / 100 | 0); },
|
||||
dddd: function (d/*, formatString*/) { return this.res.dddd[d.getDay()]; },
|
||||
ddd: function (d/*, formatString*/) { return this.res.ddd[d.getDay()]; },
|
||||
dd: function (d/*, formatString*/) { return this.res.dd[d.getDay()]; },
|
||||
Z: function (d/*, formatString*/) {
|
||||
var offset = d.getTimezoneOffset() / 0.6 | 0;
|
||||
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - (offset % 100 * 0.4 | 0))).slice(-4);
|
||||
},
|
||||
post: function (str) { return str; },
|
||||
res: _res
|
||||
},
|
||||
_parser = {
|
||||
YYYY: function (str/*, formatString */) { return this.exec(/^\d{4}/, str); },
|
||||
Y: function (str/*, formatString */) { return this.exec(/^\d{1,4}/, str); },
|
||||
MMMM: function (str/*, formatString */) {
|
||||
var result = this.find(this.res.MMMM, str);
|
||||
result.value++;
|
||||
return result;
|
||||
},
|
||||
MMM: function (str/*, formatString */) {
|
||||
var result = this.find(this.res.MMM, str);
|
||||
result.value++;
|
||||
return result;
|
||||
},
|
||||
MM: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
M: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
DD: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
D: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
HH: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
H: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
A: function (str/*, formatString */) { return this.find(this.res.A, str); },
|
||||
hh: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
h: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
mm: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
m: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
ss: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
s: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
SSS: function (str/*, formatString */) { return this.exec(/^\d{1,3}/, str); },
|
||||
SS: function (str/*, formatString */) {
|
||||
var result = this.exec(/^\d\d?/, str);
|
||||
result.value *= 10;
|
||||
return result;
|
||||
},
|
||||
S: function (str/*, formatString */) {
|
||||
var result = this.exec(/^\d/, str);
|
||||
result.value *= 100;
|
||||
return result;
|
||||
},
|
||||
Z: function (str/*, formatString */) {
|
||||
var result = this.exec(/^[\+-]\d{2}[0-5]\d/, str);
|
||||
result.value = (result.value / 100 | 0) * -60 - result.value % 100;
|
||||
return result;
|
||||
},
|
||||
h12: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
|
||||
exec: function (re, str) {
|
||||
var result = (re.exec(str) || [''])[0];
|
||||
return { value: result | 0, length: result.length };
|
||||
},
|
||||
find: function (array, str) {
|
||||
var index = -1, length = 0;
|
||||
|
||||
for (var i = 0, len = array.length, item; i < len; i++) {
|
||||
item = array[i];
|
||||
if (!str.indexOf(item) && item.length > length) {
|
||||
index = i;
|
||||
length = item.length;
|
||||
}
|
||||
}
|
||||
return { value: index, length: length };
|
||||
},
|
||||
pre: function (str) { return str; },
|
||||
res: _res
|
||||
},
|
||||
extend = function (base, props, override, res) {
|
||||
var obj = {}, key;
|
||||
|
||||
for (key in base) {
|
||||
obj[key] = base[key];
|
||||
}
|
||||
for (key in props || {}) {
|
||||
if (!(!!override ^ !!obj[key])) {
|
||||
obj[key] = props[key];
|
||||
}
|
||||
}
|
||||
if (res) {
|
||||
obj.res = res;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
var proto = {
|
||||
_formatter: _formatter,
|
||||
_parser: _parser
|
||||
};
|
||||
|
||||
/**
|
||||
* Compiling a format string
|
||||
* @param {string} formatString - a format string
|
||||
* @returns {Array.<string>} a compiled object
|
||||
*/
|
||||
proto.compile = function (formatString) {
|
||||
var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
|
||||
|
||||
while ((keys = re.exec(formatString))) {
|
||||
pattern[pattern.length] = keys[0];
|
||||
}
|
||||
return pattern;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formatting a Date and Time
|
||||
* @param {Date} dateObj - a Date object
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @param {boolean} [utc] - output as UTC
|
||||
* @returns {string} a formatted string
|
||||
*/
|
||||
proto.format = function (dateObj, arg, utc) {
|
||||
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
|
||||
offset = dateObj.getTimezoneOffset(),
|
||||
d = this.addMinutes(dateObj, utc ? offset : 0),
|
||||
formatter = this._formatter, str = '';
|
||||
|
||||
d.getTimezoneOffset = function () { return utc ? 0 : offset; };
|
||||
for (var i = 1, len = pattern.length, token; i < len; i++) {
|
||||
token = pattern[i];
|
||||
str += formatter[token] ? formatter.post(formatter[token](d, pattern[0])) : token.replace(/\[(.*)]/, '$1');
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Pre-parsing a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @returns {Object} a date structure
|
||||
*/
|
||||
proto.preparse = function (dateString, arg) {
|
||||
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
|
||||
dt = { Y: 1970, M: 1, D: 1, H: 0, A: 0, h: 0, m: 0, s: 0, S: 0, Z: 0, _index: 0, _length: 0, _match: 0 },
|
||||
comment = /\[(.*)]/, parser = this._parser, offset = 0;
|
||||
|
||||
dateString = parser.pre(dateString);
|
||||
for (var i = 1, len = pattern.length, token, result; i < len; i++) {
|
||||
token = pattern[i];
|
||||
if (parser[token]) {
|
||||
result = parser[token](dateString.slice(offset), pattern[0]);
|
||||
if (!result.length) {
|
||||
break;
|
||||
}
|
||||
offset += result.length;
|
||||
dt[result.token || token.charAt(0)] = result.value;
|
||||
dt._match++;
|
||||
} else if (token === dateString.charAt(offset) || token === ' ') {
|
||||
offset++;
|
||||
} else if (comment.test(token) && !dateString.slice(offset).indexOf(comment.exec(token)[1])) {
|
||||
offset += token.length - 2;
|
||||
} else if (token === '...') {
|
||||
offset = dateString.length;
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
dt.H = dt.H || parser.h12(dt.h, dt.A);
|
||||
dt._index = offset;
|
||||
dt._length = dateString.length;
|
||||
return dt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parsing a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @param {boolean} [utc] - input as UTC
|
||||
* @returns {Date} a constructed date
|
||||
*/
|
||||
proto.parse = function (dateString, arg, utc) {
|
||||
var dt = this.preparse(dateString, arg);
|
||||
|
||||
if (this.isValid(dt)) {
|
||||
dt.M -= dt.Y < 100 ? 22801 : 1; // 22801 = 1900 * 12 + 1
|
||||
if (utc || dt.Z) {
|
||||
return new Date(Date.UTC(dt.Y, dt.M, dt.D, dt.H, dt.m + dt.Z, dt.s, dt.S));
|
||||
}
|
||||
return new Date(dt.Y, dt.M, dt.D, dt.H, dt.m, dt.s, dt.S);
|
||||
}
|
||||
return new Date(NaN);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validation
|
||||
* @param {Object|string} arg1 - a date structure or a date string
|
||||
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
|
||||
* @returns {boolean} whether the date string is a valid date
|
||||
*/
|
||||
proto.isValid = function (arg1, arg2) {
|
||||
var dt = typeof arg1 === 'string' ? this.preparse(arg1, arg2) : arg1,
|
||||
last = [31, 28 + this.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
|
||||
|
||||
return !(
|
||||
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
|
||||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
|
||||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
|
||||
dt.Z < -720 || dt.Z > 840
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforming a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg1 - a format string or its compiled object
|
||||
* @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
|
||||
* @param {boolean} [utc] - output as UTC
|
||||
* @returns {string} a formatted string
|
||||
*/
|
||||
proto.transform = function (dateString, arg1, arg2, utc) {
|
||||
return this.format(this.parse(dateString, arg1), arg2, utc);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding years
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} years - number of years to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addYears = function (dateObj, years) {
|
||||
return this.addMonths(dateObj, years * 12);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding months
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} months - number of months to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMonths = function (dateObj, months) {
|
||||
var d = new Date(dateObj.getTime());
|
||||
|
||||
d.setMonth(d.getMonth() + months);
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding days
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} days - number of days to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addDays = function (dateObj, days) {
|
||||
var d = new Date(dateObj.getTime());
|
||||
|
||||
d.setDate(d.getDate() + days);
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding hours
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} hours - number of hours to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addHours = function (dateObj, hours) {
|
||||
return this.addMinutes(dateObj, hours * 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding minutes
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} minutes - number of minutes to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMinutes = function (dateObj, minutes) {
|
||||
return this.addSeconds(dateObj, minutes * 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding seconds
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} seconds - number of seconds to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addSeconds = function (dateObj, seconds) {
|
||||
return this.addMilliseconds(dateObj, seconds * 1000);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding milliseconds
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} milliseconds - number of milliseconds to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMilliseconds = function (dateObj, milliseconds) {
|
||||
return new Date(dateObj.getTime() + milliseconds);
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtracting two dates
|
||||
* @param {Date} date1 - a Date object
|
||||
* @param {Date} date2 - a Date object
|
||||
* @returns {Object} a result object subtracting date2 from date1
|
||||
*/
|
||||
proto.subtract = function (date1, date2) {
|
||||
var delta = date1.getTime() - date2.getTime();
|
||||
|
||||
return {
|
||||
toMilliseconds: function () {
|
||||
return delta;
|
||||
},
|
||||
toSeconds: function () {
|
||||
return delta / 1000;
|
||||
},
|
||||
toMinutes: function () {
|
||||
return delta / 60000;
|
||||
},
|
||||
toHours: function () {
|
||||
return delta / 3600000;
|
||||
},
|
||||
toDays: function () {
|
||||
return delta / 86400000;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether year is leap year
|
||||
* @param {number} y - year
|
||||
* @returns {boolean} whether year is leap year
|
||||
*/
|
||||
proto.isLeapYear = function (y) {
|
||||
return (!(y % 4) && !!(y % 100)) || !(y % 400);
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison of two dates
|
||||
* @param {Date} date1 - a Date object
|
||||
* @param {Date} date2 - a Date object
|
||||
* @returns {boolean} whether the two dates are the same day (time is ignored)
|
||||
*/
|
||||
proto.isSameDay = function (date1, date2) {
|
||||
return date1.toDateString() === date2.toDateString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Defining new locale
|
||||
* @param {string} code - language code
|
||||
* @param {Function} locale - locale installer
|
||||
* @returns {string} current language code
|
||||
*/
|
||||
proto.locale = function (code, locale) {
|
||||
if (!locales[code]) {
|
||||
locales[code] = locale;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Defining new plugin
|
||||
* @param {string} name - plugin name
|
||||
* @param {Function} plugin - plugin installer
|
||||
* @returns {void}
|
||||
*/
|
||||
proto.plugin = function (name, plugin) {
|
||||
if (!plugins[name]) {
|
||||
plugins[name] = plugin;
|
||||
}
|
||||
};
|
||||
|
||||
var localized_proto = extend(proto);
|
||||
var date = extend(proto);
|
||||
|
||||
/**
|
||||
* Changing locale
|
||||
* @param {Function|string} [locale] - locale object | language code
|
||||
* @returns {string} current language code
|
||||
*/
|
||||
date.locale = function (locale) {
|
||||
var install = typeof locale === 'function' ? locale : date.locale[locale];
|
||||
|
||||
if (!install) {
|
||||
return lang;
|
||||
}
|
||||
lang = install(proto);
|
||||
|
||||
var extension = locales[lang] || {};
|
||||
var res = extend(_res, extension.res, true);
|
||||
var formatter = extend(_formatter, extension.formatter, true, res);
|
||||
var parser = extend(_parser, extension.parser, true, res);
|
||||
|
||||
date._formatter = localized_proto._formatter = formatter;
|
||||
date._parser = localized_proto._parser = parser;
|
||||
|
||||
for (var plugin in plugins) {
|
||||
date.extend(plugins[plugin]);
|
||||
}
|
||||
|
||||
return lang;
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature extension
|
||||
* @param {Object} extension - extension object
|
||||
* @returns {void}
|
||||
*/
|
||||
date.extend = function (extension) {
|
||||
var res = extend(date._parser.res, extension.res);
|
||||
var extender = extension.extender || {};
|
||||
|
||||
date._formatter = extend(date._formatter, extension.formatter, false, res);
|
||||
date._parser = extend(date._parser, extension.parser, false, res);
|
||||
|
||||
for (var key in extender) {
|
||||
if (!date[key]) {
|
||||
date[key] = extender[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Importing plugin
|
||||
* @param {Function|string} plugin - plugin object | plugin name
|
||||
* @returns {void}
|
||||
*/
|
||||
date.plugin = function (plugin) {
|
||||
var install = typeof plugin === 'function' ? plugin : date.plugin[plugin];
|
||||
|
||||
if (install) {
|
||||
date.extend(plugins[install(proto, localized_proto)] || {});
|
||||
}
|
||||
};
|
||||
|
||||
export { date as default };
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
date-and-time (c) KNOWLEDGECODE | MIT
|
||||
*/
|
||||
var g={},l={},m="en",p={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},q={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+
|
||||
a.getFullYear()},MMMM:function(a){return this.res.MMMM[a.getMonth()]},MMM:function(a){return this.res.MMM[a.getMonth()]},MM:function(a){return("0"+(a.getMonth()+1)).slice(-2)},M:function(a){return""+(a.getMonth()+1)},DD:function(a){return("0"+a.getDate()).slice(-2)},D:function(a){return""+a.getDate()},HH:function(a){return("0"+a.getHours()).slice(-2)},H:function(a){return""+a.getHours()},A:function(a){return this.res.A[11<a.getHours()|0]},hh:function(a){return("0"+(a.getHours()%12||12)).slice(-2)},
|
||||
h:function(a){return""+(a.getHours()%12||12)},mm:function(a){return("0"+a.getMinutes()).slice(-2)},m:function(a){return""+a.getMinutes()},ss:function(a){return("0"+a.getSeconds()).slice(-2)},s:function(a){return""+a.getSeconds()},SSS:function(a){return("00"+a.getMilliseconds()).slice(-3)},SS:function(a){return("0"+(a.getMilliseconds()/10|0)).slice(-2)},S:function(a){return""+(a.getMilliseconds()/100|0)},dddd:function(a){return this.res.dddd[a.getDay()]},ddd:function(a){return this.res.ddd[a.getDay()]},
|
||||
dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.getTimezoneOffset()/.6|0;return(0<a?"-":"+")+("000"+Math.abs(a-(a%100*.4|0))).slice(-4)},post:function(a){return a},res:p},r={YYYY:function(a){return this.exec(/^\d{4}/,a)},Y:function(a){return this.exec(/^\d{1,4}/,a)},MMMM:function(a){a=this.find(this.res.MMMM,a);a.value++;return a},MMM:function(a){a=this.find(this.res.MMM,a);a.value++;return a},MM:function(a){return this.exec(/^\d\d/,a)},M:function(a){return this.exec(/^\d\d?/,a)},
|
||||
DD:function(a){return this.exec(/^\d\d/,a)},D:function(a){return this.exec(/^\d\d?/,a)},HH:function(a){return this.exec(/^\d\d/,a)},H:function(a){return this.exec(/^\d\d?/,a)},A:function(a){return this.find(this.res.A,a)},hh:function(a){return this.exec(/^\d\d/,a)},h:function(a){return this.exec(/^\d\d?/,a)},mm:function(a){return this.exec(/^\d\d/,a)},m:function(a){return this.exec(/^\d\d?/,a)},ss:function(a){return this.exec(/^\d\d/,a)},s:function(a){return this.exec(/^\d\d?/,a)},SSS:function(a){return this.exec(/^\d{1,3}/,
|
||||
a)},SS:function(a){a=this.exec(/^\d\d?/,a);a.value*=10;return a},S:function(a){a=this.exec(/^\d/,a);a.value*=100;return a},Z:function(a){a=this.exec(/^[\+-]\d{2}[0-5]\d/,a);a.value=-60*(a.value/100|0)-a.value%100;return a},h12:function(a,b){return(12===a?0:a)+12*b},exec:function(a,b){a=(a.exec(b)||[""])[0];return{value:a|0,length:a.length}},find:function(a,b){for(var c=-1,d=0,f=0,e=a.length,k;f<e;f++)k=a[f],!b.indexOf(k)&&k.length>d&&(c=f,d=k.length);return{value:c,length:d}},pre:function(a){return a},
|
||||
res:p};function t(a,b,c,d){var f={},e;for(e in a)f[e]=a[e];for(e in b||{})!!c^!!f[e]||(f[e]=b[e]);d&&(f.res=d);return f}
|
||||
var v={_formatter:q,_parser:r,compile:function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,c,d=[a];c=b.exec(a);)d[d.length]=c[0];return d},format:function(a,b,c){b="string"===typeof b?this.compile(b):b;var d=a.getTimezoneOffset();a=this.addMinutes(a,c?d:0);var f=this._formatter,e="";a.getTimezoneOffset=function(){return c?0:d};for(var k=1,u=b.length,h;k<u;k++)h=b[k],e+=f[h]?f.post(f[h](a,b[0])):h.replace(/\[(.*)]/,"$1");return e},preparse:function(a,b){b="string"===typeof b?this.compile(b):
|
||||
b;var c={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},d=/\[(.*)]/,f=this._parser,e=0;a=f.pre(a);for(var k=1,u=b.length,h,n;k<u;k++)if(h=b[k],f[h]){n=f[h](a.slice(e),b[0]);if(!n.length)break;e+=n.length;c[n.token||h.charAt(0)]=n.value;c._match++}else if(h===a.charAt(e)||" "===h)e++;else if(d.test(h)&&!a.slice(e).indexOf(d.exec(h)[1]))e+=h.length-2;else{"..."===h&&(e=a.length);break}c.H=c.H||f.h12(c.h,c.A);c._index=e;c._length=a.length;return c},parse:function(a,b,c){a=this.preparse(a,
|
||||
b);return this.isValid(a)?(a.M-=100>a.Y?22801:1,c||a.Z?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)},isValid:function(a,b){a="string"===typeof a?this.preparse(a,b):a;b=[31,28+this.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1>a._length||a._index-a._length||1>a._match||1>a.Y||9999<a.Y||1>a.M||12<a.M||1>a.D||a.D>b||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-720>a.Z||840<a.Z)},transform:function(a,
|
||||
b,c,d){return this.format(this.parse(a,b),c,d)},addYears:function(a,b){return this.addMonths(a,12*b)},addMonths:function(a,b){a=new Date(a.getTime());a.setMonth(a.getMonth()+b);return a},addDays:function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a},addHours:function(a,b){return this.addMinutes(a,60*b)},addMinutes:function(a,b){return this.addSeconds(a,60*b)},addSeconds:function(a,b){return this.addMilliseconds(a,1E3*b)},addMilliseconds:function(a,b){return new Date(a.getTime()+
|
||||
b)},subtract:function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/1E3},toMinutes:function(){return c/6E4},toHours:function(){return c/36E5},toDays:function(){return c/864E5}}},isLeapYear:function(a){return!(a%4)&&!!(a%100)||!(a%400)},isSameDay:function(a,b){return a.toDateString()===b.toDateString()},locale:function(a,b){g[a]||(g[a]=b)},plugin:function(a,b){l[a]||(l[a]=b)}},w=t(v),x=t(v);
|
||||
x.locale=function(a){a="function"===typeof a?a:x.locale[a];if(!a)return m;m=a(v);var b=g[m]||{},c=t(p,b.res,!0);a=t(q,b.formatter,!0,c);b=t(r,b.parser,!0,c);x._formatter=w._formatter=a;x._parser=w._parser=b;for(var d in l)x.extend(l[d]);return m};x.extend=function(a){var b=t(x._parser.res,a.res),c=a.extender||{};x._formatter=t(x._formatter,a.formatter,!1,b);x._parser=t(x._parser,a.parser,!1,b);for(var d in c)x[d]||(x[d]=c[d])};
|
||||
x.plugin=function(a){(a="function"===typeof a?a:x.plugin[a])&&x.extend(l[a(v,w)]||{})};export default x
|
||||
+466
@@ -0,0 +1,466 @@
|
||||
/**
|
||||
* @preserve date-and-time (c) KNOWLEDGECODE | MIT
|
||||
*/
|
||||
|
||||
var locales = {},
|
||||
plugins = {},
|
||||
lang = 'en',
|
||||
_res = {
|
||||
MMMM: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
dddd: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
ddd: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
||||
dd: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
||||
A: ['AM', 'PM']
|
||||
},
|
||||
_formatter = {
|
||||
YYYY: function (d/*, formatString*/) { return ('000' + d.getFullYear()).slice(-4); },
|
||||
YY: function (d/*, formatString*/) { return ('0' + d.getFullYear()).slice(-2); },
|
||||
Y: function (d/*, formatString*/) { return '' + d.getFullYear(); },
|
||||
MMMM: function (d/*, formatString*/) { return this.res.MMMM[d.getMonth()]; },
|
||||
MMM: function (d/*, formatString*/) { return this.res.MMM[d.getMonth()]; },
|
||||
MM: function (d/*, formatString*/) { return ('0' + (d.getMonth() + 1)).slice(-2); },
|
||||
M: function (d/*, formatString*/) { return '' + (d.getMonth() + 1); },
|
||||
DD: function (d/*, formatString*/) { return ('0' + d.getDate()).slice(-2); },
|
||||
D: function (d/*, formatString*/) { return '' + d.getDate(); },
|
||||
HH: function (d/*, formatString*/) { return ('0' + d.getHours()).slice(-2); },
|
||||
H: function (d/*, formatString*/) { return '' + d.getHours(); },
|
||||
A: function (d/*, formatString*/) { return this.res.A[d.getHours() > 11 | 0]; },
|
||||
hh: function (d/*, formatString*/) { return ('0' + (d.getHours() % 12 || 12)).slice(-2); },
|
||||
h: function (d/*, formatString*/) { return '' + (d.getHours() % 12 || 12); },
|
||||
mm: function (d/*, formatString*/) { return ('0' + d.getMinutes()).slice(-2); },
|
||||
m: function (d/*, formatString*/) { return '' + d.getMinutes(); },
|
||||
ss: function (d/*, formatString*/) { return ('0' + d.getSeconds()).slice(-2); },
|
||||
s: function (d/*, formatString*/) { return '' + d.getSeconds(); },
|
||||
SSS: function (d/*, formatString*/) { return ('00' + d.getMilliseconds()).slice(-3); },
|
||||
SS: function (d/*, formatString*/) { return ('0' + (d.getMilliseconds() / 10 | 0)).slice(-2); },
|
||||
S: function (d/*, formatString*/) { return '' + (d.getMilliseconds() / 100 | 0); },
|
||||
dddd: function (d/*, formatString*/) { return this.res.dddd[d.getDay()]; },
|
||||
ddd: function (d/*, formatString*/) { return this.res.ddd[d.getDay()]; },
|
||||
dd: function (d/*, formatString*/) { return this.res.dd[d.getDay()]; },
|
||||
Z: function (d/*, formatString*/) {
|
||||
var offset = d.getTimezoneOffset() / 0.6 | 0;
|
||||
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - (offset % 100 * 0.4 | 0))).slice(-4);
|
||||
},
|
||||
post: function (str) { return str; },
|
||||
res: _res
|
||||
},
|
||||
_parser = {
|
||||
YYYY: function (str/*, formatString */) { return this.exec(/^\d{4}/, str); },
|
||||
Y: function (str/*, formatString */) { return this.exec(/^\d{1,4}/, str); },
|
||||
MMMM: function (str/*, formatString */) {
|
||||
var result = this.find(this.res.MMMM, str);
|
||||
result.value++;
|
||||
return result;
|
||||
},
|
||||
MMM: function (str/*, formatString */) {
|
||||
var result = this.find(this.res.MMM, str);
|
||||
result.value++;
|
||||
return result;
|
||||
},
|
||||
MM: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
M: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
DD: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
D: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
HH: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
H: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
A: function (str/*, formatString */) { return this.find(this.res.A, str); },
|
||||
hh: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
h: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
mm: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
m: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
ss: function (str/*, formatString */) { return this.exec(/^\d\d/, str); },
|
||||
s: function (str/*, formatString */) { return this.exec(/^\d\d?/, str); },
|
||||
SSS: function (str/*, formatString */) { return this.exec(/^\d{1,3}/, str); },
|
||||
SS: function (str/*, formatString */) {
|
||||
var result = this.exec(/^\d\d?/, str);
|
||||
result.value *= 10;
|
||||
return result;
|
||||
},
|
||||
S: function (str/*, formatString */) {
|
||||
var result = this.exec(/^\d/, str);
|
||||
result.value *= 100;
|
||||
return result;
|
||||
},
|
||||
Z: function (str/*, formatString */) {
|
||||
var result = this.exec(/^[\+-]\d{2}[0-5]\d/, str);
|
||||
result.value = (result.value / 100 | 0) * -60 - result.value % 100;
|
||||
return result;
|
||||
},
|
||||
h12: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
|
||||
exec: function (re, str) {
|
||||
var result = (re.exec(str) || [''])[0];
|
||||
return { value: result | 0, length: result.length };
|
||||
},
|
||||
find: function (array, str) {
|
||||
var index = -1, length = 0;
|
||||
|
||||
for (var i = 0, len = array.length, item; i < len; i++) {
|
||||
item = array[i];
|
||||
if (!str.indexOf(item) && item.length > length) {
|
||||
index = i;
|
||||
length = item.length;
|
||||
}
|
||||
}
|
||||
return { value: index, length: length };
|
||||
},
|
||||
pre: function (str) { return str; },
|
||||
res: _res
|
||||
},
|
||||
extend = function (base, props, override, res) {
|
||||
var obj = {}, key;
|
||||
|
||||
for (key in base) {
|
||||
obj[key] = base[key];
|
||||
}
|
||||
for (key in props || {}) {
|
||||
if (!(!!override ^ !!obj[key])) {
|
||||
obj[key] = props[key];
|
||||
}
|
||||
}
|
||||
if (res) {
|
||||
obj.res = res;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
var proto = {
|
||||
_formatter: _formatter,
|
||||
_parser: _parser
|
||||
};
|
||||
|
||||
/**
|
||||
* Compiling a format string
|
||||
* @param {string} formatString - a format string
|
||||
* @returns {Array.<string>} a compiled object
|
||||
*/
|
||||
proto.compile = function (formatString) {
|
||||
var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
|
||||
|
||||
while ((keys = re.exec(formatString))) {
|
||||
pattern[pattern.length] = keys[0];
|
||||
}
|
||||
return pattern;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formatting a Date and Time
|
||||
* @param {Date} dateObj - a Date object
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @param {boolean} [utc] - output as UTC
|
||||
* @returns {string} a formatted string
|
||||
*/
|
||||
proto.format = function (dateObj, arg, utc) {
|
||||
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
|
||||
offset = dateObj.getTimezoneOffset(),
|
||||
d = this.addMinutes(dateObj, utc ? offset : 0),
|
||||
formatter = this._formatter, str = '';
|
||||
|
||||
d.getTimezoneOffset = function () { return utc ? 0 : offset; };
|
||||
for (var i = 1, len = pattern.length, token; i < len; i++) {
|
||||
token = pattern[i];
|
||||
str += formatter[token] ? formatter.post(formatter[token](d, pattern[0])) : token.replace(/\[(.*)]/, '$1');
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Pre-parsing a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @returns {Object} a date structure
|
||||
*/
|
||||
proto.preparse = function (dateString, arg) {
|
||||
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
|
||||
dt = { Y: 1970, M: 1, D: 1, H: 0, A: 0, h: 0, m: 0, s: 0, S: 0, Z: 0, _index: 0, _length: 0, _match: 0 },
|
||||
comment = /\[(.*)]/, parser = this._parser, offset = 0;
|
||||
|
||||
dateString = parser.pre(dateString);
|
||||
for (var i = 1, len = pattern.length, token, result; i < len; i++) {
|
||||
token = pattern[i];
|
||||
if (parser[token]) {
|
||||
result = parser[token](dateString.slice(offset), pattern[0]);
|
||||
if (!result.length) {
|
||||
break;
|
||||
}
|
||||
offset += result.length;
|
||||
dt[result.token || token.charAt(0)] = result.value;
|
||||
dt._match++;
|
||||
} else if (token === dateString.charAt(offset) || token === ' ') {
|
||||
offset++;
|
||||
} else if (comment.test(token) && !dateString.slice(offset).indexOf(comment.exec(token)[1])) {
|
||||
offset += token.length - 2;
|
||||
} else if (token === '...') {
|
||||
offset = dateString.length;
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
dt.H = dt.H || parser.h12(dt.h, dt.A);
|
||||
dt._index = offset;
|
||||
dt._length = dateString.length;
|
||||
return dt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parsing a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg - a format string or its compiled object
|
||||
* @param {boolean} [utc] - input as UTC
|
||||
* @returns {Date} a constructed date
|
||||
*/
|
||||
proto.parse = function (dateString, arg, utc) {
|
||||
var dt = this.preparse(dateString, arg);
|
||||
|
||||
if (this.isValid(dt)) {
|
||||
dt.M -= dt.Y < 100 ? 22801 : 1; // 22801 = 1900 * 12 + 1
|
||||
if (utc || dt.Z) {
|
||||
return new Date(Date.UTC(dt.Y, dt.M, dt.D, dt.H, dt.m + dt.Z, dt.s, dt.S));
|
||||
}
|
||||
return new Date(dt.Y, dt.M, dt.D, dt.H, dt.m, dt.s, dt.S);
|
||||
}
|
||||
return new Date(NaN);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validation
|
||||
* @param {Object|string} arg1 - a date structure or a date string
|
||||
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
|
||||
* @returns {boolean} whether the date string is a valid date
|
||||
*/
|
||||
proto.isValid = function (arg1, arg2) {
|
||||
var dt = typeof arg1 === 'string' ? this.preparse(arg1, arg2) : arg1,
|
||||
last = [31, 28 + this.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
|
||||
|
||||
return !(
|
||||
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
|
||||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
|
||||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
|
||||
dt.Z < -720 || dt.Z > 840
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforming a Date and Time string
|
||||
* @param {string} dateString - a date string
|
||||
* @param {string|Array.<string>} arg1 - a format string or its compiled object
|
||||
* @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
|
||||
* @param {boolean} [utc] - output as UTC
|
||||
* @returns {string} a formatted string
|
||||
*/
|
||||
proto.transform = function (dateString, arg1, arg2, utc) {
|
||||
return this.format(this.parse(dateString, arg1), arg2, utc);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding years
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} years - number of years to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addYears = function (dateObj, years) {
|
||||
return this.addMonths(dateObj, years * 12);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding months
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} months - number of months to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMonths = function (dateObj, months) {
|
||||
var d = new Date(dateObj.getTime());
|
||||
|
||||
d.setMonth(d.getMonth() + months);
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding days
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} days - number of days to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addDays = function (dateObj, days) {
|
||||
var d = new Date(dateObj.getTime());
|
||||
|
||||
d.setDate(d.getDate() + days);
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding hours
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} hours - number of hours to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addHours = function (dateObj, hours) {
|
||||
return this.addMinutes(dateObj, hours * 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding minutes
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} minutes - number of minutes to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMinutes = function (dateObj, minutes) {
|
||||
return this.addSeconds(dateObj, minutes * 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding seconds
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} seconds - number of seconds to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addSeconds = function (dateObj, seconds) {
|
||||
return this.addMilliseconds(dateObj, seconds * 1000);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adding milliseconds
|
||||
* @param {Date} dateObj - a date object
|
||||
* @param {number} milliseconds - number of milliseconds to add
|
||||
* @returns {Date} a date after adding the value
|
||||
*/
|
||||
proto.addMilliseconds = function (dateObj, milliseconds) {
|
||||
return new Date(dateObj.getTime() + milliseconds);
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtracting two dates
|
||||
* @param {Date} date1 - a Date object
|
||||
* @param {Date} date2 - a Date object
|
||||
* @returns {Object} a result object subtracting date2 from date1
|
||||
*/
|
||||
proto.subtract = function (date1, date2) {
|
||||
var delta = date1.getTime() - date2.getTime();
|
||||
|
||||
return {
|
||||
toMilliseconds: function () {
|
||||
return delta;
|
||||
},
|
||||
toSeconds: function () {
|
||||
return delta / 1000;
|
||||
},
|
||||
toMinutes: function () {
|
||||
return delta / 60000;
|
||||
},
|
||||
toHours: function () {
|
||||
return delta / 3600000;
|
||||
},
|
||||
toDays: function () {
|
||||
return delta / 86400000;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether year is leap year
|
||||
* @param {number} y - year
|
||||
* @returns {boolean} whether year is leap year
|
||||
*/
|
||||
proto.isLeapYear = function (y) {
|
||||
return (!(y % 4) && !!(y % 100)) || !(y % 400);
|
||||
};
|
||||
|
||||
/**
|
||||
* Comparison of two dates
|
||||
* @param {Date} date1 - a Date object
|
||||
* @param {Date} date2 - a Date object
|
||||
* @returns {boolean} whether the two dates are the same day (time is ignored)
|
||||
*/
|
||||
proto.isSameDay = function (date1, date2) {
|
||||
return date1.toDateString() === date2.toDateString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Defining new locale
|
||||
* @param {string} code - language code
|
||||
* @param {Function} locale - locale installer
|
||||
* @returns {string} current language code
|
||||
*/
|
||||
proto.locale = function (code, locale) {
|
||||
if (!locales[code]) {
|
||||
locales[code] = locale;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Defining new plugin
|
||||
* @param {string} name - plugin name
|
||||
* @param {Function} plugin - plugin installer
|
||||
* @returns {void}
|
||||
*/
|
||||
proto.plugin = function (name, plugin) {
|
||||
if (!plugins[name]) {
|
||||
plugins[name] = plugin;
|
||||
}
|
||||
};
|
||||
|
||||
var localized_proto = extend(proto);
|
||||
var date = extend(proto);
|
||||
|
||||
/**
|
||||
* Changing locale
|
||||
* @param {Function|string} [locale] - locale object | language code
|
||||
* @returns {string} current language code
|
||||
*/
|
||||
date.locale = function (locale) {
|
||||
var install = typeof locale === 'function' ? locale : date.locale[locale];
|
||||
|
||||
if (!install) {
|
||||
return lang;
|
||||
}
|
||||
lang = install(proto);
|
||||
|
||||
var extension = locales[lang] || {};
|
||||
var res = extend(_res, extension.res, true);
|
||||
var formatter = extend(_formatter, extension.formatter, true, res);
|
||||
var parser = extend(_parser, extension.parser, true, res);
|
||||
|
||||
date._formatter = localized_proto._formatter = formatter;
|
||||
date._parser = localized_proto._parser = parser;
|
||||
|
||||
for (var plugin in plugins) {
|
||||
date.extend(plugins[plugin]);
|
||||
}
|
||||
|
||||
return lang;
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature extension
|
||||
* @param {Object} extension - extension object
|
||||
* @returns {void}
|
||||
*/
|
||||
date.extend = function (extension) {
|
||||
var res = extend(date._parser.res, extension.res);
|
||||
var extender = extension.extender || {};
|
||||
|
||||
date._formatter = extend(date._formatter, extension.formatter, false, res);
|
||||
date._parser = extend(date._parser, extension.parser, false, res);
|
||||
|
||||
for (var key in extender) {
|
||||
if (!date[key]) {
|
||||
date[key] = extender[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Importing plugin
|
||||
* @param {Function|string} plugin - plugin object | plugin name
|
||||
* @returns {void}
|
||||
*/
|
||||
date.plugin = function (plugin) {
|
||||
var install = typeof plugin === 'function' ? plugin : date.plugin[plugin];
|
||||
|
||||
if (install) {
|
||||
date.extend(plugins[install(proto, localized_proto)] || {});
|
||||
}
|
||||
};
|
||||
|
||||
export { date as default };
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Arabic (ar)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ar = function (date) {
|
||||
var code = 'ar';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],
|
||||
MMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],
|
||||
dddd: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
ddd: ['أحد', 'إثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
dd: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
A: ['ص', 'م']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '٠': 0, '١': 1, '٢': 2, '٣': 3, '٤': 4, '٥': 5, '٦': 6, '٧': 7, '٨': 8, '٩': 9 };
|
||||
return str.replace(/[٠١٢٣٤٥٦٧٨٩]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ar as default };
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Arabic (ar)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ar = function (date) {
|
||||
var code = 'ar';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],
|
||||
MMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],
|
||||
dddd: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
ddd: ['أحد', 'إثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
dd: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
A: ['ص', 'م']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '٠': 0, '١': 1, '٢': 2, '٣': 3, '٤': 4, '٥': 5, '٦': 6, '٧': 7, '٨': 8, '٩': 9 };
|
||||
return str.replace(/[٠١٢٣٤٥٦٧٨٩]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ar as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Azerbaijani (az)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var az = function (date) {
|
||||
var code = 'az';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['yanvar', 'fevral', 'mart', 'aprel', 'may', 'iyun', 'iyul', 'avqust', 'sentyabr', 'oktyabr', 'noyabr', 'dekabr'],
|
||||
MMM: ['yan', 'fev', 'mar', 'apr', 'may', 'iyn', 'iyl', 'avq', 'sen', 'okt', 'noy', 'dek'],
|
||||
dddd: ['Bazar', 'Bazar ertəsi', 'Çərşənbə axşamı', 'Çərşənbə', 'Cümə axşamı', 'Cümə', 'Şənbə'],
|
||||
ddd: ['Baz', 'BzE', 'ÇAx', 'Çər', 'CAx', 'Cüm', 'Şən'],
|
||||
dd: ['Bz', 'BE', 'ÇA', 'Çə', 'CA', 'Cü', 'Şə'],
|
||||
A: ['gecə', 'səhər', 'gündüz', 'axşam']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // gecə
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // səhər
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // gündüz
|
||||
}
|
||||
return this.res.A[3]; // axşam
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // gecə, səhər
|
||||
}
|
||||
return h > 11 ? h : h + 12; // gündüz, axşam
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { az as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Azerbaijani (az)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var az = function (date) {
|
||||
var code = 'az';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['yanvar', 'fevral', 'mart', 'aprel', 'may', 'iyun', 'iyul', 'avqust', 'sentyabr', 'oktyabr', 'noyabr', 'dekabr'],
|
||||
MMM: ['yan', 'fev', 'mar', 'apr', 'may', 'iyn', 'iyl', 'avq', 'sen', 'okt', 'noy', 'dek'],
|
||||
dddd: ['Bazar', 'Bazar ertəsi', 'Çərşənbə axşamı', 'Çərşənbə', 'Cümə axşamı', 'Cümə', 'Şənbə'],
|
||||
ddd: ['Baz', 'BzE', 'ÇAx', 'Çər', 'CAx', 'Cüm', 'Şən'],
|
||||
dd: ['Bz', 'BE', 'ÇA', 'Çə', 'CA', 'Cü', 'Şə'],
|
||||
A: ['gecə', 'səhər', 'gündüz', 'axşam']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // gecə
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // səhər
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // gündüz
|
||||
}
|
||||
return this.res.A[3]; // axşam
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // gecə, səhər
|
||||
}
|
||||
return h > 11 ? h : h + 12; // gündüz, axşam
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { az as default };
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Bengali (bn)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var bn = function (date) {
|
||||
var code = 'bn';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['জানুয়ারী', 'ফেবুয়ারী', 'মার্চ', 'এপ্রিল', 'মে', 'জুন', 'জুলাই', 'অগাস্ট', 'সেপ্টেম্বর', 'অক্টোবর', 'নভেম্বর', 'ডিসেম্বর'],
|
||||
MMM: ['জানু', 'ফেব', 'মার্চ', 'এপর', 'মে', 'জুন', 'জুল', 'অগ', 'সেপ্ট', 'অক্টো', 'নভ', 'ডিসেম্'],
|
||||
dddd: ['রবিবার', 'সোমবার', 'মঙ্গলবার', 'বুধবার', 'বৃহস্পত্তিবার', 'শুক্রবার', 'শনিবার'],
|
||||
ddd: ['রবি', 'সোম', 'মঙ্গল', 'বুধ', 'বৃহস্পত্তি', 'শুক্র', 'শনি'],
|
||||
dd: ['রব', 'সম', 'মঙ্গ', 'বু', 'ব্রিহ', 'শু', 'শনি'],
|
||||
A: ['রাত', 'সকাল', 'দুপুর', 'বিকাল']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // রাত
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // সকাল
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // দুপুর
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // বিকাল
|
||||
}
|
||||
return this.res.A[0]; // রাত
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // রাত
|
||||
} else if (a < 2) {
|
||||
return h; // সকাল
|
||||
} else if (a < 3) {
|
||||
return h > 9 ? h : h + 12; // দুপুর
|
||||
}
|
||||
return h + 12; // বিকাল
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { bn as default };
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Bengali (bn)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var bn = function (date) {
|
||||
var code = 'bn';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['জানুয়ারী', 'ফেবুয়ারী', 'মার্চ', 'এপ্রিল', 'মে', 'জুন', 'জুলাই', 'অগাস্ট', 'সেপ্টেম্বর', 'অক্টোবর', 'নভেম্বর', 'ডিসেম্বর'],
|
||||
MMM: ['জানু', 'ফেব', 'মার্চ', 'এপর', 'মে', 'জুন', 'জুল', 'অগ', 'সেপ্ট', 'অক্টো', 'নভ', 'ডিসেম্'],
|
||||
dddd: ['রবিবার', 'সোমবার', 'মঙ্গলবার', 'বুধবার', 'বৃহস্পত্তিবার', 'শুক্রবার', 'শনিবার'],
|
||||
ddd: ['রবি', 'সোম', 'মঙ্গল', 'বুধ', 'বৃহস্পত্তি', 'শুক্র', 'শনি'],
|
||||
dd: ['রব', 'সম', 'মঙ্গ', 'বু', 'ব্রিহ', 'শু', 'শনি'],
|
||||
A: ['রাত', 'সকাল', 'দুপুর', 'বিকাল']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // রাত
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // সকাল
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // দুপুর
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // বিকাল
|
||||
}
|
||||
return this.res.A[0]; // রাত
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // রাত
|
||||
} else if (a < 2) {
|
||||
return h; // সকাল
|
||||
} else if (a < 3) {
|
||||
return h > 9 ? h : h + 12; // দুপুর
|
||||
}
|
||||
return h + 12; // বিকাল
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { bn as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Czech (cs)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var cs = function (date) {
|
||||
var code = 'cs';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'],
|
||||
MMM: ['led', 'úno', 'bře', 'dub', 'kvě', 'čvn', 'čvc', 'srp', 'zář', 'říj', 'lis', 'pro'],
|
||||
dddd: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
|
||||
ddd: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
|
||||
dd: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { cs as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Czech (cs)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var cs = function (date) {
|
||||
var code = 'cs';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'],
|
||||
MMM: ['led', 'úno', 'bře', 'dub', 'kvě', 'čvn', 'čvc', 'srp', 'zář', 'říj', 'lis', 'pro'],
|
||||
dddd: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
|
||||
ddd: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
|
||||
dd: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { cs as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve German (de)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var de = function (date) {
|
||||
var code = 'de';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
||||
MMM: ['Jan.', 'Febr.', 'Mrz.', 'Apr.', 'Mai', 'Jun.', 'Jul.', 'Aug.', 'Sept.', 'Okt.', 'Nov.', 'Dez.'],
|
||||
dddd: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
|
||||
ddd: ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.'],
|
||||
dd: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
||||
A: ['Uhr nachmittags', 'Uhr morgens']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { de as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve German (de)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var de = function (date) {
|
||||
var code = 'de';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
||||
MMM: ['Jan.', 'Febr.', 'Mrz.', 'Apr.', 'Mai', 'Jun.', 'Jul.', 'Aug.', 'Sept.', 'Okt.', 'Nov.', 'Dez.'],
|
||||
dddd: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
|
||||
ddd: ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.'],
|
||||
dd: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
||||
A: ['Uhr nachmittags', 'Uhr morgens']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { de as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Danish (DK)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var dk = function (date) {
|
||||
var code = 'dk';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'december'],
|
||||
MMM: ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
|
||||
dddd: ['søndag', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'],
|
||||
ddd: ['søn', 'man', 'tir', 'ons', 'tors', 'fre', 'lør'],
|
||||
dd: ['sø', 'ma', 'ti', 'on', 'to', 'fr', 'lø']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { dk as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Danish (DK)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var dk = function (date) {
|
||||
var code = 'dk';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'december'],
|
||||
MMM: ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
|
||||
dddd: ['søndag', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'],
|
||||
ddd: ['søn', 'man', 'tir', 'ons', 'tors', 'fre', 'lør'],
|
||||
dd: ['sø', 'ma', 'ti', 'on', 'to', 'fr', 'lø']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { dk as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Greek (el)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var el = function (date) {
|
||||
var code = 'el';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: [
|
||||
['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
|
||||
['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου']
|
||||
],
|
||||
MMM: ['Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μαϊ', 'Ιουν', 'Ιουλ', 'Αυγ', 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'],
|
||||
dddd: ['Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο'],
|
||||
ddd: ['Κυρ', 'Δευ', 'Τρι', 'Τετ', 'Πεμ', 'Παρ', 'Σαβ'],
|
||||
dd: ['Κυ', 'Δε', 'Τρ', 'Τε', 'Πε', 'Πα', 'Σα'],
|
||||
A: ['πμ', 'μμ']
|
||||
},
|
||||
formatter: {
|
||||
MMMM: function (d, formatString) {
|
||||
return this.res.MMMM[/D.*MMMM/.test(formatString) | 0][d.getMonth()];
|
||||
},
|
||||
hh: function (d) {
|
||||
return ('0' + d.getHours() % 12).slice(-2);
|
||||
},
|
||||
h: function (d) {
|
||||
return d.getHours() % 12;
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMMM[/D.*MMMM/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { el as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Greek (el)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var el = function (date) {
|
||||
var code = 'el';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: [
|
||||
['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
|
||||
['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου']
|
||||
],
|
||||
MMM: ['Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μαϊ', 'Ιουν', 'Ιουλ', 'Αυγ', 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'],
|
||||
dddd: ['Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο'],
|
||||
ddd: ['Κυρ', 'Δευ', 'Τρι', 'Τετ', 'Πεμ', 'Παρ', 'Σαβ'],
|
||||
dd: ['Κυ', 'Δε', 'Τρ', 'Τε', 'Πε', 'Πα', 'Σα'],
|
||||
A: ['πμ', 'μμ']
|
||||
},
|
||||
formatter: {
|
||||
MMMM: function (d, formatString) {
|
||||
return this.res.MMMM[/D.*MMMM/.test(formatString) | 0][d.getMonth()];
|
||||
},
|
||||
hh: function (d) {
|
||||
return ('0' + d.getHours() % 12).slice(-2);
|
||||
},
|
||||
h: function (d) {
|
||||
return d.getHours() % 12;
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMMM[/D.*MMMM/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { el as default };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Englis (en)
|
||||
* @preserve This is a dummy module.
|
||||
*/
|
||||
|
||||
var en = function (date) {
|
||||
var code = 'en';
|
||||
|
||||
return code;
|
||||
};
|
||||
|
||||
export { en as default };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Englis (en)
|
||||
* @preserve This is a dummy module.
|
||||
*/
|
||||
|
||||
var en = function (date) {
|
||||
var code = 'en';
|
||||
|
||||
return code;
|
||||
};
|
||||
|
||||
export { en as default };
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Spanish (es)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var es = function (date) {
|
||||
var code = 'es';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
|
||||
MMM: ['ene.', 'feb.', 'mar.', 'abr.', 'may.', 'jun.', 'jul.', 'ago.', 'sep.', 'oct.', 'nov.', 'dic.'],
|
||||
dddd: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
|
||||
ddd: ['dom.', 'lun.', 'mar.', 'mié.', 'jue.', 'vie.', 'sáb.'],
|
||||
dd: ['do', 'lu', 'ma', 'mi', 'ju', 'vi', 'sá'],
|
||||
A: ['de la mañana', 'de la tarde', 'de la noche']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 12) {
|
||||
return this.res.A[0]; // de la mañana
|
||||
} else if (h < 19) {
|
||||
return this.res.A[1]; // de la tarde
|
||||
}
|
||||
return this.res.A[2]; // de la noche
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h; // de la mañana
|
||||
}
|
||||
return h > 11 ? h : h + 12; // de la tarde, de la noche
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { es as default };
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Spanish (es)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var es = function (date) {
|
||||
var code = 'es';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
|
||||
MMM: ['ene.', 'feb.', 'mar.', 'abr.', 'may.', 'jun.', 'jul.', 'ago.', 'sep.', 'oct.', 'nov.', 'dic.'],
|
||||
dddd: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
|
||||
ddd: ['dom.', 'lun.', 'mar.', 'mié.', 'jue.', 'vie.', 'sáb.'],
|
||||
dd: ['do', 'lu', 'ma', 'mi', 'ju', 'vi', 'sá'],
|
||||
A: ['de la mañana', 'de la tarde', 'de la noche']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 12) {
|
||||
return this.res.A[0]; // de la mañana
|
||||
} else if (h < 19) {
|
||||
return this.res.A[1]; // de la tarde
|
||||
}
|
||||
return this.res.A[2]; // de la noche
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h; // de la mañana
|
||||
}
|
||||
return h > 11 ? h : h + 12; // de la tarde, de la noche
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { es as default };
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Persian (fa)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var fa = function (date) {
|
||||
var code = 'fa';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'],
|
||||
MMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'],
|
||||
dddd: ['یکشنبه', 'دوشنبه', 'سهشنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'],
|
||||
ddd: ['یکشنبه', 'دوشنبه', 'سهشنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'],
|
||||
dd: ['ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش'],
|
||||
A: ['قبل از ظهر', 'بعد از ظهر']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '۰': 0, '۱': 1, '۲': 2, '۳': 3, '۴': 4, '۵': 5, '۶': 6, '۷': 7, '۸': 8, '۹': 9 };
|
||||
return str.replace(/[۰۱۲۳۴۵۶۷۸۹]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { fa as default };
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Persian (fa)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var fa = function (date) {
|
||||
var code = 'fa';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'],
|
||||
MMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'],
|
||||
dddd: ['یکشنبه', 'دوشنبه', 'سهشنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'],
|
||||
ddd: ['یکشنبه', 'دوشنبه', 'سهشنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'],
|
||||
dd: ['ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش'],
|
||||
A: ['قبل از ظهر', 'بعد از ظهر']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '۰': 0, '۱': 1, '۲': 2, '۳': 3, '۴': 4, '۵': 5, '۶': 6, '۷': 7, '۸': 8, '۹': 9 };
|
||||
return str.replace(/[۰۱۲۳۴۵۶۷۸۹]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { fa as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve French (fr)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var fr = function (date) {
|
||||
var code = 'fr';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
|
||||
MMM: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
|
||||
dddd: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
|
||||
ddd: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
|
||||
dd: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
|
||||
A: ['matin', 'l\'après-midi']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { fr as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve French (fr)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var fr = function (date) {
|
||||
var code = 'fr';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
|
||||
MMM: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
|
||||
dddd: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
|
||||
ddd: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
|
||||
dd: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
|
||||
A: ['matin', 'l\'après-midi']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { fr as default };
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Hindi (hi)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var hi = function (date) {
|
||||
var code = 'hi';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['जनवरी', 'फ़रवरी', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अगस्त', 'सितम्बर', 'अक्टूबर', 'नवम्बर', 'दिसम्बर'],
|
||||
MMM: ['जन.', 'फ़र.', 'मार्च', 'अप्रै.', 'मई', 'जून', 'जुल.', 'अग.', 'सित.', 'अक्टू.', 'नव.', 'दिस.'],
|
||||
dddd: ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरूवार', 'शुक्रवार', 'शनिवार'],
|
||||
ddd: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरू', 'शुक्र', 'शनि'],
|
||||
dd: ['र', 'सो', 'मं', 'बु', 'गु', 'शु', 'श'],
|
||||
A: ['रात', 'सुबह', 'दोपहर', 'शाम']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // रात
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // सुबह
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // दोपहर
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // शाम
|
||||
}
|
||||
return this.res.A[0]; // रात
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // रात
|
||||
} else if (a < 2) {
|
||||
return h; // सुबह
|
||||
} else if (a < 3) {
|
||||
return h > 9 ? h : h + 12; // दोपहर
|
||||
}
|
||||
return h + 12; // शाम
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { hi as default };
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Hindi (hi)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var hi = function (date) {
|
||||
var code = 'hi';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['जनवरी', 'फ़रवरी', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अगस्त', 'सितम्बर', 'अक्टूबर', 'नवम्बर', 'दिसम्बर'],
|
||||
MMM: ['जन.', 'फ़र.', 'मार्च', 'अप्रै.', 'मई', 'जून', 'जुल.', 'अग.', 'सित.', 'अक्टू.', 'नव.', 'दिस.'],
|
||||
dddd: ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरूवार', 'शुक्रवार', 'शनिवार'],
|
||||
ddd: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरू', 'शुक्र', 'शनि'],
|
||||
dd: ['र', 'सो', 'मं', 'बु', 'गु', 'शु', 'श'],
|
||||
A: ['रात', 'सुबह', 'दोपहर', 'शाम']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // रात
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // सुबह
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // दोपहर
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // शाम
|
||||
}
|
||||
return this.res.A[0]; // रात
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // रात
|
||||
} else if (a < 2) {
|
||||
return h; // सुबह
|
||||
} else if (a < 3) {
|
||||
return h > 9 ? h : h + 12; // दोपहर
|
||||
}
|
||||
return h + 12; // शाम
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { hi as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Hungarian (hu)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var hu = function (date) {
|
||||
var code = 'hu';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december'],
|
||||
MMM: ['jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'],
|
||||
dddd: ['vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'],
|
||||
ddd: ['vas', 'hét', 'kedd', 'sze', 'csüt', 'pén', 'szo'],
|
||||
dd: ['v', 'h', 'k', 'sze', 'cs', 'p', 'szo'],
|
||||
A: ['de', 'du']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { hu as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Hungarian (hu)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var hu = function (date) {
|
||||
var code = 'hu';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december'],
|
||||
MMM: ['jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'],
|
||||
dddd: ['vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'],
|
||||
ddd: ['vas', 'hét', 'kedd', 'sze', 'csüt', 'pén', 'szo'],
|
||||
dd: ['v', 'h', 'k', 'sze', 'cs', 'p', 'szo'],
|
||||
A: ['de', 'du']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { hu as default };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Indonesian (id)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var id = function (date) {
|
||||
var code = 'id';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Ags', 'Sep', 'Okt', 'Nov', 'Des'],
|
||||
dddd: ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'],
|
||||
ddd: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
|
||||
dd: ['Mg', 'Sn', 'Sl', 'Rb', 'Km', 'Jm', 'Sb'],
|
||||
A: ['pagi', 'siang', 'sore', 'malam']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 11) {
|
||||
return this.res.A[0]; // pagi
|
||||
} else if (h < 15) {
|
||||
return this.res.A[1]; // siang
|
||||
} else if (h < 19) {
|
||||
return this.res.A[2]; // sore
|
||||
}
|
||||
return this.res.A[3]; // malam
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h; // pagi
|
||||
} else if (a < 2) {
|
||||
return h >= 11 ? h : h + 12; // siang
|
||||
}
|
||||
return h + 12; // sore, malam
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { id as default };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Indonesian (id)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var id = function (date) {
|
||||
var code = 'id';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Ags', 'Sep', 'Okt', 'Nov', 'Des'],
|
||||
dddd: ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'],
|
||||
ddd: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
|
||||
dd: ['Mg', 'Sn', 'Sl', 'Rb', 'Km', 'Jm', 'Sb'],
|
||||
A: ['pagi', 'siang', 'sore', 'malam']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 11) {
|
||||
return this.res.A[0]; // pagi
|
||||
} else if (h < 15) {
|
||||
return this.res.A[1]; // siang
|
||||
} else if (h < 19) {
|
||||
return this.res.A[2]; // sore
|
||||
}
|
||||
return this.res.A[3]; // malam
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h; // pagi
|
||||
} else if (a < 2) {
|
||||
return h >= 11 ? h : h + 12; // siang
|
||||
}
|
||||
return h + 12; // sore, malam
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { id as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Italian (it)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var it = function (date) {
|
||||
var code = 'it';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre'],
|
||||
MMM: ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'],
|
||||
dddd: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
|
||||
ddd: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
|
||||
dd: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'],
|
||||
A: ['di mattina', 'di pomerrigio']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { it as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Italian (it)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var it = function (date) {
|
||||
var code = 'it';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre'],
|
||||
MMM: ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'],
|
||||
dddd: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
|
||||
ddd: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
|
||||
dd: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'],
|
||||
A: ['di mattina', 'di pomerrigio']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { it as default };
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Japanese (ja)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ja = function (date) {
|
||||
var code = 'ja';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
MMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
dddd: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'],
|
||||
ddd: ['日', '月', '火', '水', '木', '金', '土'],
|
||||
dd: ['日', '月', '火', '水', '木', '金', '土'],
|
||||
A: ['午前', '午後']
|
||||
},
|
||||
formatter: {
|
||||
hh: function (d) {
|
||||
return ('0' + d.getHours() % 12).slice(-2);
|
||||
},
|
||||
h: function (d) {
|
||||
return d.getHours() % 12;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ja as default };
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Japanese (ja)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ja = function (date) {
|
||||
var code = 'ja';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
MMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
dddd: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'],
|
||||
ddd: ['日', '月', '火', '水', '木', '金', '土'],
|
||||
dd: ['日', '月', '火', '水', '木', '金', '土'],
|
||||
A: ['午前', '午後']
|
||||
},
|
||||
formatter: {
|
||||
hh: function (d) {
|
||||
return ('0' + d.getHours() % 12).slice(-2);
|
||||
},
|
||||
h: function (d) {
|
||||
return d.getHours() % 12;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ja as default };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Javanese (jv)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var jv = function (date) {
|
||||
var code = 'jv';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'Nopember', 'Desember'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Ags', 'Sep', 'Okt', 'Nop', 'Des'],
|
||||
dddd: ['Minggu', 'Senen', 'Seloso', 'Rebu', 'Kemis', 'Jemuwah', 'Septu'],
|
||||
ddd: ['Min', 'Sen', 'Sel', 'Reb', 'Kem', 'Jem', 'Sep'],
|
||||
dd: ['Mg', 'Sn', 'Sl', 'Rb', 'Km', 'Jm', 'Sp'],
|
||||
A: ['enjing', 'siyang', 'sonten', 'ndalu']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 11) {
|
||||
return this.res.A[0]; // enjing
|
||||
} else if (h < 15) {
|
||||
return this.res.A[1]; // siyang
|
||||
} else if (h < 19) {
|
||||
return this.res.A[2]; // sonten
|
||||
}
|
||||
return this.res.A[3]; // ndalu
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h; // enjing
|
||||
} else if (a < 2) {
|
||||
return h >= 11 ? h : h + 12; // siyang
|
||||
}
|
||||
return h + 12; // sonten, ndalu
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { jv as default };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Javanese (jv)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var jv = function (date) {
|
||||
var code = 'jv';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'Nopember', 'Desember'],
|
||||
MMM: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Ags', 'Sep', 'Okt', 'Nop', 'Des'],
|
||||
dddd: ['Minggu', 'Senen', 'Seloso', 'Rebu', 'Kemis', 'Jemuwah', 'Septu'],
|
||||
ddd: ['Min', 'Sen', 'Sel', 'Reb', 'Kem', 'Jem', 'Sep'],
|
||||
dd: ['Mg', 'Sn', 'Sl', 'Rb', 'Km', 'Jm', 'Sp'],
|
||||
A: ['enjing', 'siyang', 'sonten', 'ndalu']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 11) {
|
||||
return this.res.A[0]; // enjing
|
||||
} else if (h < 15) {
|
||||
return this.res.A[1]; // siyang
|
||||
} else if (h < 19) {
|
||||
return this.res.A[2]; // sonten
|
||||
}
|
||||
return this.res.A[3]; // ndalu
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h; // enjing
|
||||
} else if (a < 2) {
|
||||
return h >= 11 ? h : h + 12; // siyang
|
||||
}
|
||||
return h + 12; // sonten, ndalu
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { jv as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Korean (ko)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ko = function (date) {
|
||||
var code = 'ko';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
|
||||
MMM: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
|
||||
dddd: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
|
||||
ddd: ['일', '월', '화', '수', '목', '금', '토'],
|
||||
dd: ['일', '월', '화', '수', '목', '금', '토'],
|
||||
A: ['오전', '오후']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ko as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Korean (ko)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ko = function (date) {
|
||||
var code = 'ko';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
|
||||
MMM: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
|
||||
dddd: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
|
||||
ddd: ['일', '월', '화', '수', '목', '금', '토'],
|
||||
dd: ['일', '월', '화', '수', '목', '금', '토'],
|
||||
A: ['오전', '오후']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ko as default };
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Burmese (my)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var my = function (date) {
|
||||
var code = 'my';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ဇန်နဝါရီ', 'ဖေဖော်ဝါရီ', 'မတ်', 'ဧပြီ', 'မေ', 'ဇွန်', 'ဇူလိုင်', 'သြဂုတ်', 'စက်တင်ဘာ', 'အောက်တိုဘာ', 'နိုဝင်ဘာ', 'ဒီဇင်ဘာ'],
|
||||
MMM: ['ဇန်', 'ဖေ', 'မတ်', 'ပြီ', 'မေ', 'ဇွန်', 'လိုင်', 'သြ', 'စက်', 'အောက်', 'နို', 'ဒီ'],
|
||||
dddd: ['တနင်္ဂနွေ', 'တနင်္လာ', 'အင်္ဂါ', 'ဗုဒ္ဓဟူး', 'ကြာသပတေး', 'သောကြာ', 'စနေ'],
|
||||
ddd: ['နွေ', 'လာ', 'ဂါ', 'ဟူး', 'ကြာ', 'သော', 'နေ'],
|
||||
dd: ['နွေ', 'လာ', 'ဂါ', 'ဟူး', 'ကြာ', 'သော', 'နေ']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['၀', '၁', '၂', '၃', '၄', '၅', '၆', '၇', '၈', '၉'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '၀': 0, '၁': 1, '၂': 2, '၃': 3, '၄': 4, '၅': 5, '၆': 6, '၇': 7, '၈': 8, '၉': 9 };
|
||||
return str.replace(/[၀၁၂၃၄၅၆၇၈၉]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { my as default };
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Burmese (my)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var my = function (date) {
|
||||
var code = 'my';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ဇန်နဝါရီ', 'ဖေဖော်ဝါရီ', 'မတ်', 'ဧပြီ', 'မေ', 'ဇွန်', 'ဇူလိုင်', 'သြဂုတ်', 'စက်တင်ဘာ', 'အောက်တိုဘာ', 'နိုဝင်ဘာ', 'ဒီဇင်ဘာ'],
|
||||
MMM: ['ဇန်', 'ဖေ', 'မတ်', 'ပြီ', 'မေ', 'ဇွန်', 'လိုင်', 'သြ', 'စက်', 'အောက်', 'နို', 'ဒီ'],
|
||||
dddd: ['တနင်္ဂနွေ', 'တနင်္လာ', 'အင်္ဂါ', 'ဗုဒ္ဓဟူး', 'ကြာသပတေး', 'သောကြာ', 'စနေ'],
|
||||
ddd: ['နွေ', 'လာ', 'ဂါ', 'ဟူး', 'ကြာ', 'သော', 'နေ'],
|
||||
dd: ['နွေ', 'လာ', 'ဂါ', 'ဟူး', 'ကြာ', 'သော', 'နေ']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['၀', '၁', '၂', '၃', '၄', '၅', '၆', '၇', '၈', '၉'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '၀': 0, '၁': 1, '၂': 2, '၃': 3, '၄': 4, '၅': 5, '၆': 6, '၇': 7, '၈': 8, '၉': 9 };
|
||||
return str.replace(/[၀၁၂၃၄၅၆၇၈၉]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { my as default };
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Dutch (nl)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var nl = function (date) {
|
||||
var code = 'nl';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
|
||||
MMM: [
|
||||
['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
|
||||
['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
|
||||
],
|
||||
dddd: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
|
||||
ddd: ['zo.', 'ma.', 'di.', 'wo.', 'do.', 'vr.', 'za.'],
|
||||
dd: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za']
|
||||
},
|
||||
formatter: {
|
||||
MMM: function (d, formatString) {
|
||||
return this.res.MMM[/-MMM-/.test(formatString) | 0][d.getMonth()];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMM[/-MMM-/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { nl as default };
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Dutch (nl)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var nl = function (date) {
|
||||
var code = 'nl';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
|
||||
MMM: [
|
||||
['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
|
||||
['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
|
||||
],
|
||||
dddd: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
|
||||
ddd: ['zo.', 'ma.', 'di.', 'wo.', 'do.', 'vr.', 'za.'],
|
||||
dd: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za']
|
||||
},
|
||||
formatter: {
|
||||
MMM: function (d, formatString) {
|
||||
return this.res.MMM[/-MMM-/.test(formatString) | 0][d.getMonth()];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMM[/-MMM-/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { nl as default };
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Punjabi (pa-in)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var pa_in = function (date) {
|
||||
var code = 'pa-in';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ਜਨਵਰੀ', 'ਫ਼ਰਵਰੀ', 'ਮਾਰਚ', 'ਅਪ੍ਰੈਲ', 'ਮਈ', 'ਜੂਨ', 'ਜੁਲਾਈ', 'ਅਗਸਤ', 'ਸਤੰਬਰ', 'ਅਕਤੂਬਰ', 'ਨਵੰਬਰ', 'ਦਸੰਬਰ'],
|
||||
MMM: ['ਜਨਵਰੀ', 'ਫ਼ਰਵਰੀ', 'ਮਾਰਚ', 'ਅਪ੍ਰੈਲ', 'ਮਈ', 'ਜੂਨ', 'ਜੁਲਾਈ', 'ਅਗਸਤ', 'ਸਤੰਬਰ', 'ਅਕਤੂਬਰ', 'ਨਵੰਬਰ', 'ਦਸੰਬਰ'],
|
||||
dddd: ['ਐਤਵਾਰ', 'ਸੋਮਵਾਰ', 'ਮੰਗਲਵਾਰ', 'ਬੁਧਵਾਰ', 'ਵੀਰਵਾਰ', 'ਸ਼ੁੱਕਰਵਾਰ', 'ਸ਼ਨੀਚਰਵਾਰ'],
|
||||
ddd: ['ਐਤ', 'ਸੋਮ', 'ਮੰਗਲ', 'ਬੁਧ', 'ਵੀਰ', 'ਸ਼ੁਕਰ', 'ਸ਼ਨੀ'],
|
||||
dd: ['ਐਤ', 'ਸੋਮ', 'ਮੰਗਲ', 'ਬੁਧ', 'ਵੀਰ', 'ਸ਼ੁਕਰ', 'ਸ਼ਨੀ'],
|
||||
A: ['ਰਾਤ', 'ਸਵੇਰ', 'ਦੁਪਹਿਰ', 'ਸ਼ਾਮ']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // ਰਾਤ
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // ਸਵੇਰ
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // ਦੁਪਹਿਰ
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // ਸ਼ਾਮ
|
||||
}
|
||||
return this.res.A[0]; // ਰਾਤ
|
||||
},
|
||||
post: function (str) {
|
||||
var num = ['੦', '੧', '੨', '੩', '੪', '੫', '੬', '੭', '੮', '੯'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // ਰਾਤ
|
||||
} else if (a < 2) {
|
||||
return h; // ਸਵੇਰ
|
||||
} else if (a < 3) {
|
||||
return h >= 10 ? h : h + 12; // ਦੁਪਹਿਰ
|
||||
}
|
||||
return h + 12; // ਸ਼ਾਮ
|
||||
},
|
||||
pre: function (str) {
|
||||
var map = { '੦': 0, '੧': 1, '੨': 2, '੩': 3, '੪': 4, '੫': 5, '੬': 6, '੭': 7, '੮': 8, '੯': 9 };
|
||||
return str.replace(/[੦੧੨੩੪੫੬੭੮੯]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { pa_in as default };
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Punjabi (pa-in)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var pa_in = function (date) {
|
||||
var code = 'pa-in';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ਜਨਵਰੀ', 'ਫ਼ਰਵਰੀ', 'ਮਾਰਚ', 'ਅਪ੍ਰੈਲ', 'ਮਈ', 'ਜੂਨ', 'ਜੁਲਾਈ', 'ਅਗਸਤ', 'ਸਤੰਬਰ', 'ਅਕਤੂਬਰ', 'ਨਵੰਬਰ', 'ਦਸੰਬਰ'],
|
||||
MMM: ['ਜਨਵਰੀ', 'ਫ਼ਰਵਰੀ', 'ਮਾਰਚ', 'ਅਪ੍ਰੈਲ', 'ਮਈ', 'ਜੂਨ', 'ਜੁਲਾਈ', 'ਅਗਸਤ', 'ਸਤੰਬਰ', 'ਅਕਤੂਬਰ', 'ਨਵੰਬਰ', 'ਦਸੰਬਰ'],
|
||||
dddd: ['ਐਤਵਾਰ', 'ਸੋਮਵਾਰ', 'ਮੰਗਲਵਾਰ', 'ਬੁਧਵਾਰ', 'ਵੀਰਵਾਰ', 'ਸ਼ੁੱਕਰਵਾਰ', 'ਸ਼ਨੀਚਰਵਾਰ'],
|
||||
ddd: ['ਐਤ', 'ਸੋਮ', 'ਮੰਗਲ', 'ਬੁਧ', 'ਵੀਰ', 'ਸ਼ੁਕਰ', 'ਸ਼ਨੀ'],
|
||||
dd: ['ਐਤ', 'ਸੋਮ', 'ਮੰਗਲ', 'ਬੁਧ', 'ਵੀਰ', 'ਸ਼ੁਕਰ', 'ਸ਼ਨੀ'],
|
||||
A: ['ਰਾਤ', 'ਸਵੇਰ', 'ਦੁਪਹਿਰ', 'ਸ਼ਾਮ']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // ਰਾਤ
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // ਸਵੇਰ
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // ਦੁਪਹਿਰ
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // ਸ਼ਾਮ
|
||||
}
|
||||
return this.res.A[0]; // ਰਾਤ
|
||||
},
|
||||
post: function (str) {
|
||||
var num = ['੦', '੧', '੨', '੩', '੪', '੫', '੬', '੭', '੮', '੯'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // ਰਾਤ
|
||||
} else if (a < 2) {
|
||||
return h; // ਸਵੇਰ
|
||||
} else if (a < 3) {
|
||||
return h >= 10 ? h : h + 12; // ਦੁਪਹਿਰ
|
||||
}
|
||||
return h + 12; // ਸ਼ਾਮ
|
||||
},
|
||||
pre: function (str) {
|
||||
var map = { '੦': 0, '੧': 1, '੨': 2, '੩': 3, '੪': 4, '੫': 5, '੬': 6, '੭': 7, '੮': 8, '੯': 9 };
|
||||
return str.replace(/[੦੧੨੩੪੫੬੭੮੯]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { pa_in as default };
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Polish (pl)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var pl = function (date) {
|
||||
var code = 'pl';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: [
|
||||
['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
|
||||
['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia']
|
||||
],
|
||||
MMM: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru'],
|
||||
dddd: ['niedziela', 'poniedziałek', 'wtorek', 'środa', 'czwartek', 'piątek', 'sobota'],
|
||||
ddd: ['nie', 'pon', 'wt', 'śr', 'czw', 'pt', 'sb'],
|
||||
dd: ['Nd', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So']
|
||||
},
|
||||
formatter: {
|
||||
MMMM: function (d, formatString) {
|
||||
return this.res.MMMM[/D MMMM/.test(formatString) | 0][d.getMonth()];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMMM[/D MMMM/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { pl as default };
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Polish (pl)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var pl = function (date) {
|
||||
var code = 'pl';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: [
|
||||
['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
|
||||
['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia']
|
||||
],
|
||||
MMM: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru'],
|
||||
dddd: ['niedziela', 'poniedziałek', 'wtorek', 'środa', 'czwartek', 'piątek', 'sobota'],
|
||||
ddd: ['nie', 'pon', 'wt', 'śr', 'czw', 'pt', 'sb'],
|
||||
dd: ['Nd', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So']
|
||||
},
|
||||
formatter: {
|
||||
MMMM: function (d, formatString) {
|
||||
return this.res.MMMM[/D MMMM/.test(formatString) | 0][d.getMonth()];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMMM[/D MMMM/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { pl as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Portuguese (pt)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var pt = function (date) {
|
||||
var code = 'pt';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
|
||||
MMM: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
|
||||
dddd: ['Domingo', 'Segunda-Feira', 'Terça-Feira', 'Quarta-Feira', 'Quinta-Feira', 'Sexta-Feira', 'Sábado'],
|
||||
ddd: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
|
||||
dd: ['Dom', '2ª', '3ª', '4ª', '5ª', '6ª', 'Sáb'],
|
||||
A: ['da madrugada', 'da manhã', 'da tarde', 'da noite']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 5) {
|
||||
return this.res.A[0]; // da madrugada
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // da manhã
|
||||
} else if (h < 19) {
|
||||
return this.res.A[2]; // da tarde
|
||||
}
|
||||
return this.res.A[3]; // da noite
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // da madrugada, da manhã
|
||||
}
|
||||
return h > 11 ? h : h + 12; // da tarde, da noite
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { pt as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Portuguese (pt)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var pt = function (date) {
|
||||
var code = 'pt';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
|
||||
MMM: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
|
||||
dddd: ['Domingo', 'Segunda-Feira', 'Terça-Feira', 'Quarta-Feira', 'Quinta-Feira', 'Sexta-Feira', 'Sábado'],
|
||||
ddd: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
|
||||
dd: ['Dom', '2ª', '3ª', '4ª', '5ª', '6ª', 'Sáb'],
|
||||
A: ['da madrugada', 'da manhã', 'da tarde', 'da noite']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 5) {
|
||||
return this.res.A[0]; // da madrugada
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // da manhã
|
||||
} else if (h < 19) {
|
||||
return this.res.A[2]; // da tarde
|
||||
}
|
||||
return this.res.A[3]; // da noite
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // da madrugada, da manhã
|
||||
}
|
||||
return h > 11 ? h : h + 12; // da tarde, da noite
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { pt as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Romanian (ro)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ro = function (date) {
|
||||
var code = 'ro';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ianuarie', 'februarie', 'martie', 'aprilie', 'mai', 'iunie', 'iulie', 'august', 'septembrie', 'octombrie', 'noiembrie', 'decembrie'],
|
||||
MMM: ['ian.', 'febr.', 'mart.', 'apr.', 'mai', 'iun.', 'iul.', 'aug.', 'sept.', 'oct.', 'nov.', 'dec.'],
|
||||
dddd: ['duminică', 'luni', 'marți', 'miercuri', 'joi', 'vineri', 'sâmbătă'],
|
||||
ddd: ['Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sâm'],
|
||||
dd: ['Du', 'Lu', 'Ma', 'Mi', 'Jo', 'Vi', 'Sâ']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ro as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Romanian (ro)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ro = function (date) {
|
||||
var code = 'ro';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['ianuarie', 'februarie', 'martie', 'aprilie', 'mai', 'iunie', 'iulie', 'august', 'septembrie', 'octombrie', 'noiembrie', 'decembrie'],
|
||||
MMM: ['ian.', 'febr.', 'mart.', 'apr.', 'mai', 'iun.', 'iul.', 'aug.', 'sept.', 'oct.', 'nov.', 'dec.'],
|
||||
dddd: ['duminică', 'luni', 'marți', 'miercuri', 'joi', 'vineri', 'sâmbătă'],
|
||||
ddd: ['Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sâm'],
|
||||
dd: ['Du', 'Lu', 'Ma', 'Mi', 'Jo', 'Vi', 'Sâ']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ro as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Russian (ru)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ru = function (date) {
|
||||
var code = 'ru';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря'],
|
||||
MMM: ['янв', 'фев', 'мар', 'апр', 'мая', 'июня', 'июля', 'авг', 'сен', 'окт', 'ноя', 'дек'],
|
||||
dddd: ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'],
|
||||
ddd: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
|
||||
dd: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
|
||||
A: ['ночи', 'утра', 'дня', 'вечера']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // ночи
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // утра
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // дня
|
||||
}
|
||||
return this.res.A[3]; // вечера
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // ночи, утра
|
||||
}
|
||||
return h > 11 ? h : h + 12; // дня, вечера
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ru as default };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Russian (ru)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ru = function (date) {
|
||||
var code = 'ru';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря'],
|
||||
MMM: ['янв', 'фев', 'мар', 'апр', 'мая', 'июня', 'июля', 'авг', 'сен', 'окт', 'ноя', 'дек'],
|
||||
dddd: ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'],
|
||||
ddd: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
|
||||
dd: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
|
||||
A: ['ночи', 'утра', 'дня', 'вечера']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // ночи
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // утра
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // дня
|
||||
}
|
||||
return this.res.A[3]; // вечера
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // ночи, утра
|
||||
}
|
||||
return h > 11 ? h : h + 12; // дня, вечера
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { ru as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Kinyarwanda (rw)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var rw = function (date) {
|
||||
var code = 'rw';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Mutarama', 'Gashyantare', 'Werurwe', 'Mata', 'Gicurasi', 'Kamena', 'Nyakanga', 'Kanama', 'Nzeri', 'Ukwakira', 'Ugushyingo', 'Ukuboza'],
|
||||
MMM: ['Mtr', 'Gas', 'Wer', 'Mta', 'Gic', 'Kmn', 'Nyk', 'Knm', 'Nze', 'Ukw', 'Ugu', 'Uku'],
|
||||
dddd: ['Ku cyumweru', 'Ku wambere', 'Ku wakabiri', 'Ku wagatatu', 'Ku wakane', 'Ku wagatanu', 'Ku wagatandatu'],
|
||||
ddd: ['Cyu', 'Mbe', 'Kbr', 'Gtt', 'Kne', 'Gtn', 'Gtd'],
|
||||
dd: ['Cy', 'Mb', 'Kb', 'Gt', 'Kn', 'Gn', 'Gd']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { rw as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Kinyarwanda (rw)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var rw = function (date) {
|
||||
var code = 'rw';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Mutarama', 'Gashyantare', 'Werurwe', 'Mata', 'Gicurasi', 'Kamena', 'Nyakanga', 'Kanama', 'Nzeri', 'Ukwakira', 'Ugushyingo', 'Ukuboza'],
|
||||
MMM: ['Mtr', 'Gas', 'Wer', 'Mta', 'Gic', 'Kmn', 'Nyk', 'Knm', 'Nze', 'Ukw', 'Ugu', 'Uku'],
|
||||
dddd: ['Ku cyumweru', 'Ku wambere', 'Ku wakabiri', 'Ku wagatatu', 'Ku wakane', 'Ku wagatanu', 'Ku wagatandatu'],
|
||||
ddd: ['Cyu', 'Mbe', 'Kbr', 'Gtt', 'Kne', 'Gtn', 'Gtd'],
|
||||
dd: ['Cy', 'Mb', 'Kb', 'Gt', 'Kn', 'Gn', 'Gd']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { rw as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Serbian (sr)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var sr = function (date) {
|
||||
var code = 'sr';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
|
||||
MMM: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
|
||||
dddd: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
|
||||
ddd: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
|
||||
dd: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { sr as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Serbian (sr)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var sr = function (date) {
|
||||
var code = 'sr';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
|
||||
MMM: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
|
||||
dddd: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
|
||||
ddd: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
|
||||
dd: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { sr as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Thai (th)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var th = function (date) {
|
||||
var code = 'th';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],
|
||||
MMM: ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'],
|
||||
dddd: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'],
|
||||
ddd: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัส', 'ศุกร์', 'เสาร์'],
|
||||
dd: ['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'],
|
||||
A: ['ก่อนเที่ยง', 'หลังเที่ยง']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { th as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Thai (th)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var th = function (date) {
|
||||
var code = 'th';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],
|
||||
MMM: ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'],
|
||||
dddd: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'],
|
||||
ddd: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัส', 'ศุกร์', 'เสาร์'],
|
||||
dd: ['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'],
|
||||
A: ['ก่อนเที่ยง', 'หลังเที่ยง']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { th as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Turkish (tr)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var tr = function (date) {
|
||||
var code = 'tr';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
|
||||
MMM: ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'],
|
||||
dddd: ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'],
|
||||
ddd: ['Paz', 'Pts', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'],
|
||||
dd: ['Pz', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { tr as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Turkish (tr)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var tr = function (date) {
|
||||
var code = 'tr';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
|
||||
MMM: ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'],
|
||||
dddd: ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'],
|
||||
ddd: ['Paz', 'Pts', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'],
|
||||
dd: ['Pz', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { tr as default };
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Ukrainian (uk)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var uk = function (date) {
|
||||
var code = 'uk';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['січня', 'лютого', 'березня', 'квітня', 'травня', 'червня', 'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня'],
|
||||
MMM: ['січ', 'лют', 'бер', 'квіт', 'трав', 'черв', 'лип', 'серп', 'вер', 'жовт', 'лист', 'груд'],
|
||||
dddd: [
|
||||
['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
|
||||
['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
|
||||
['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи']
|
||||
],
|
||||
ddd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
|
||||
dd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
|
||||
A: ['ночі', 'ранку', 'дня', 'вечора']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // ночі
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // ранку
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // дня
|
||||
}
|
||||
return this.res.A[3]; // вечора
|
||||
},
|
||||
dddd: function (d, formatString) {
|
||||
var type = 0;
|
||||
if (/(\[[ВвУу]\]) ?dddd/.test(formatString)) {
|
||||
type = 1;
|
||||
} else if (/\[?(?:минулої|наступної)? ?\] ?dddd/.test(formatString)) {
|
||||
type = 2;
|
||||
}
|
||||
return this.res.dddd[type][d.getDay()];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // ночі, ранку
|
||||
}
|
||||
return h > 11 ? h : h + 12; // дня, вечора
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { uk as default };
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Ukrainian (uk)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var uk = function (date) {
|
||||
var code = 'uk';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['січня', 'лютого', 'березня', 'квітня', 'травня', 'червня', 'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня'],
|
||||
MMM: ['січ', 'лют', 'бер', 'квіт', 'трав', 'черв', 'лип', 'серп', 'вер', 'жовт', 'лист', 'груд'],
|
||||
dddd: [
|
||||
['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
|
||||
['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
|
||||
['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи']
|
||||
],
|
||||
ddd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
|
||||
dd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
|
||||
A: ['ночі', 'ранку', 'дня', 'вечора']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // ночі
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // ранку
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // дня
|
||||
}
|
||||
return this.res.A[3]; // вечора
|
||||
},
|
||||
dddd: function (d, formatString) {
|
||||
var type = 0;
|
||||
if (/(\[[ВвУу]\]) ?dddd/.test(formatString)) {
|
||||
type = 1;
|
||||
} else if (/\[?(?:минулої|наступної)? ?\] ?dddd/.test(formatString)) {
|
||||
type = 2;
|
||||
}
|
||||
return this.res.dddd[type][d.getDay()];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // ночі, ранку
|
||||
}
|
||||
return h > 11 ? h : h + 12; // дня, вечора
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { uk as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Uzbek (uz)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var uz = function (date) {
|
||||
var code = 'uz';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['январ', 'феврал', 'март', 'апрел', 'май', 'июн', 'июл', 'август', 'сентябр', 'октябр', 'ноябр', 'декабр'],
|
||||
MMM: ['янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек'],
|
||||
dddd: ['Якшанба', 'Душанба', 'Сешанба', 'Чоршанба', 'Пайшанба', 'Жума', 'Шанба'],
|
||||
ddd: ['Якш', 'Душ', 'Сеш', 'Чор', 'Пай', 'Жум', 'Шан'],
|
||||
dd: ['Як', 'Ду', 'Се', 'Чо', 'Па', 'Жу', 'Ша']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { uz as default };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Uzbek (uz)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var uz = function (date) {
|
||||
var code = 'uz';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['январ', 'феврал', 'март', 'апрел', 'май', 'июн', 'июл', 'август', 'сентябр', 'октябр', 'ноябр', 'декабр'],
|
||||
MMM: ['янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек'],
|
||||
dddd: ['Якшанба', 'Душанба', 'Сешанба', 'Чоршанба', 'Пайшанба', 'Жума', 'Шанба'],
|
||||
ddd: ['Якш', 'Душ', 'Сеш', 'Чор', 'Пай', 'Жум', 'Шан'],
|
||||
dd: ['Як', 'Ду', 'Се', 'Чо', 'Па', 'Жу', 'Ша']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { uz as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Vietnamese (vi)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var vi = function (date) {
|
||||
var code = 'vi';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['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'],
|
||||
MMM: ['Th01', 'Th02', 'Th03', 'Th04', 'Th05', 'Th06', 'Th07', 'Th08', 'Th09', 'Th10', 'Th11', 'Th12'],
|
||||
dddd: ['chủ nhật', 'thứ hai', 'thứ ba', 'thứ tư', 'thứ năm', 'thứ sáu', 'thứ bảy'],
|
||||
ddd: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
|
||||
dd: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
|
||||
A: ['sa', 'ch']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { vi as default };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Vietnamese (vi)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var vi = function (date) {
|
||||
var code = 'vi';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['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'],
|
||||
MMM: ['Th01', 'Th02', 'Th03', 'Th04', 'Th05', 'Th06', 'Th07', 'Th08', 'Th09', 'Th10', 'Th11', 'Th12'],
|
||||
dddd: ['chủ nhật', 'thứ hai', 'thứ ba', 'thứ tư', 'thứ năm', 'thứ sáu', 'thứ bảy'],
|
||||
ddd: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
|
||||
dd: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
|
||||
A: ['sa', 'ch']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { vi as default };
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Chinese (zh-cn)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var zh_cn = function (date) {
|
||||
var code = 'zh-cn';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
||||
MMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
dddd: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
||||
ddd: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
||||
dd: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
A: ['凌晨', '早上', '上午', '中午', '下午', '晚上']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var hm = d.getHours() * 100 + d.getMinutes();
|
||||
if (hm < 600) {
|
||||
return this.res.A[0]; // 凌晨
|
||||
} else if (hm < 900) {
|
||||
return this.res.A[1]; // 早上
|
||||
} else if (hm < 1130) {
|
||||
return this.res.A[2]; // 上午
|
||||
} else if (hm < 1230) {
|
||||
return this.res.A[3]; // 中午
|
||||
} else if (hm < 1800) {
|
||||
return this.res.A[4]; // 下午
|
||||
}
|
||||
return this.res.A[5]; // 晚上
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 4) {
|
||||
return h; // 凌晨, 早上, 上午, 中午
|
||||
}
|
||||
return h > 11 ? h : h + 12; // 下午, 晚上
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { zh_cn as default };
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Chinese (zh-cn)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var zh_cn = function (date) {
|
||||
var code = 'zh-cn';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
||||
MMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
dddd: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
||||
ddd: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
||||
dd: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
A: ['凌晨', '早上', '上午', '中午', '下午', '晚上']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var hm = d.getHours() * 100 + d.getMinutes();
|
||||
if (hm < 600) {
|
||||
return this.res.A[0]; // 凌晨
|
||||
} else if (hm < 900) {
|
||||
return this.res.A[1]; // 早上
|
||||
} else if (hm < 1130) {
|
||||
return this.res.A[2]; // 上午
|
||||
} else if (hm < 1230) {
|
||||
return this.res.A[3]; // 中午
|
||||
} else if (hm < 1800) {
|
||||
return this.res.A[4]; // 下午
|
||||
}
|
||||
return this.res.A[5]; // 晚上
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 4) {
|
||||
return h; // 凌晨, 早上, 上午, 中午
|
||||
}
|
||||
return h > 11 ? h : h + 12; // 下午, 晚上
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { zh_cn as default };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Chinese (zh-tw)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var zh_tw = function (date) {
|
||||
var code = 'zh-tw';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
||||
MMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
dddd: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
||||
ddd: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
||||
dd: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
A: ['早上', '上午', '中午', '下午', '晚上']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var hm = d.getHours() * 100 + d.getMinutes();
|
||||
if (hm < 900) {
|
||||
return this.res.A[0]; // 早上
|
||||
} else if (hm < 1130) {
|
||||
return this.res.A[1]; // 上午
|
||||
} else if (hm < 1230) {
|
||||
return this.res.A[2]; // 中午
|
||||
} else if (hm < 1800) {
|
||||
return this.res.A[3]; // 下午
|
||||
}
|
||||
return this.res.A[4]; // 晚上
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 3) {
|
||||
return h; // 早上, 上午, 中午
|
||||
}
|
||||
return h > 11 ? h : h + 12; // 下午, 晚上
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { zh_tw as default };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Chinese (zh-tw)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var zh_tw = function (date) {
|
||||
var code = 'zh-tw';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
||||
MMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
|
||||
dddd: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
||||
ddd: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
||||
dd: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
A: ['早上', '上午', '中午', '下午', '晚上']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var hm = d.getHours() * 100 + d.getMinutes();
|
||||
if (hm < 900) {
|
||||
return this.res.A[0]; // 早上
|
||||
} else if (hm < 1130) {
|
||||
return this.res.A[1]; // 上午
|
||||
} else if (hm < 1230) {
|
||||
return this.res.A[2]; // 中午
|
||||
} else if (hm < 1800) {
|
||||
return this.res.A[3]; // 下午
|
||||
}
|
||||
return this.res.A[4]; // 晚上
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 3) {
|
||||
return h; // 早上, 上午, 中午
|
||||
}
|
||||
return h > 11 ? h : h + 12; // 下午, 晚上
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
export { zh_tw as default };
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve day-of-week
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'day-of-week';
|
||||
|
||||
date.plugin(name, {
|
||||
parser: {
|
||||
dddd: function (str) { return this.find(this.res.dddd, str); },
|
||||
ddd: function (str) { return this.find(this.res.ddd, str); },
|
||||
dd: function (str) { return this.find(this.res.dd, str); }
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve day-of-week
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'day-of-week';
|
||||
|
||||
date.plugin(name, {
|
||||
parser: {
|
||||
dddd: function (str) { return this.find(this.res.dddd, str); },
|
||||
ddd: function (str) { return this.find(this.res.ddd, str); },
|
||||
dd: function (str) { return this.find(this.res.dd, str); }
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve meridiem
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'meridiem';
|
||||
|
||||
date.plugin(name, {
|
||||
res: {
|
||||
AA: ['A.M.', 'P.M.'],
|
||||
a: ['am', 'pm'],
|
||||
aa: ['a.m.', 'p.m.']
|
||||
},
|
||||
formatter: {
|
||||
AA: function (d) {
|
||||
return this.res.AA[d.getHours() > 11 | 0];
|
||||
},
|
||||
a: function (d) {
|
||||
return this.res.a[d.getHours() > 11 | 0];
|
||||
},
|
||||
aa: function (d) {
|
||||
return this.res.aa[d.getHours() > 11 | 0];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
AA: function (str) {
|
||||
var result = this.find(this.res.AA, str);
|
||||
result.token = 'A';
|
||||
return result;
|
||||
},
|
||||
a: function (str) {
|
||||
var result = this.find(this.res.a, str);
|
||||
result.token = 'A';
|
||||
return result;
|
||||
},
|
||||
aa: function (str) {
|
||||
var result = this.find(this.res.aa, str);
|
||||
result.token = 'A';
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve meridiem
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'meridiem';
|
||||
|
||||
date.plugin(name, {
|
||||
res: {
|
||||
AA: ['A.M.', 'P.M.'],
|
||||
a: ['am', 'pm'],
|
||||
aa: ['a.m.', 'p.m.']
|
||||
},
|
||||
formatter: {
|
||||
AA: function (d) {
|
||||
return this.res.AA[d.getHours() > 11 | 0];
|
||||
},
|
||||
a: function (d) {
|
||||
return this.res.a[d.getHours() > 11 | 0];
|
||||
},
|
||||
aa: function (d) {
|
||||
return this.res.aa[d.getHours() > 11 | 0];
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
AA: function (str) {
|
||||
var result = this.find(this.res.AA, str);
|
||||
result.token = 'A';
|
||||
return result;
|
||||
},
|
||||
a: function (str) {
|
||||
var result = this.find(this.res.a, str);
|
||||
result.token = 'A';
|
||||
return result;
|
||||
},
|
||||
aa: function (str) {
|
||||
var result = this.find(this.res.aa, str);
|
||||
result.token = 'A';
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve microsecond
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'microsecond';
|
||||
|
||||
date.plugin(name, {
|
||||
parser: {
|
||||
SSSSSS: function (str) {
|
||||
var result = this.exec(/^\d{1,6}/, str);
|
||||
result.value = result.value / 1000 | 0;
|
||||
return result;
|
||||
},
|
||||
SSSSS: function (str) {
|
||||
var result = this.exec(/^\d{1,5}/, str);
|
||||
result.value = result.value / 100 | 0;
|
||||
return result;
|
||||
},
|
||||
SSSS: function (str) {
|
||||
var result = this.exec(/^\d{1,4}/, str);
|
||||
result.value = result.value / 10 | 0;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve microsecond
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'microsecond';
|
||||
|
||||
date.plugin(name, {
|
||||
parser: {
|
||||
SSSSSS: function (str) {
|
||||
var result = this.exec(/^\d{1,6}/, str);
|
||||
result.value = result.value / 1000 | 0;
|
||||
return result;
|
||||
},
|
||||
SSSSS: function (str) {
|
||||
var result = this.exec(/^\d{1,5}/, str);
|
||||
result.value = result.value / 100 | 0;
|
||||
return result;
|
||||
},
|
||||
SSSS: function (str) {
|
||||
var result = this.exec(/^\d{1,4}/, str);
|
||||
result.value = result.value / 10 | 0;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve ordinal
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'ordinal';
|
||||
|
||||
date.plugin(name, {
|
||||
formatter: {
|
||||
DDD: function (d) {
|
||||
var day = d.getDate();
|
||||
|
||||
switch (day) {
|
||||
case 1:
|
||||
case 21:
|
||||
case 31:
|
||||
return day + 'st';
|
||||
case 2:
|
||||
case 22:
|
||||
return day + 'nd';
|
||||
case 3:
|
||||
case 23:
|
||||
return day + 'rd';
|
||||
default:
|
||||
return day + 'th';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve ordinal
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'ordinal';
|
||||
|
||||
date.plugin(name, {
|
||||
formatter: {
|
||||
DDD: function (d) {
|
||||
var day = d.getDate();
|
||||
|
||||
switch (day) {
|
||||
case 1:
|
||||
case 21:
|
||||
case 31:
|
||||
return day + 'st';
|
||||
case 2:
|
||||
case 22:
|
||||
return day + 'nd';
|
||||
case 3:
|
||||
case 23:
|
||||
return day + 'rd';
|
||||
default:
|
||||
return day + 'th';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve timespan
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var timeSpan = function (date1, date2) {
|
||||
var milliseconds = function (dt, time) {
|
||||
dt.S = time;
|
||||
return dt;
|
||||
},
|
||||
seconds = function (dt, time) {
|
||||
dt.s = time / 1000 | 0;
|
||||
return milliseconds(dt, Math.abs(time) % 1000);
|
||||
},
|
||||
minutes = function (dt, time) {
|
||||
dt.m = time / 60000 | 0;
|
||||
return seconds(dt, Math.abs(time) % 60000);
|
||||
},
|
||||
hours = function (dt, time) {
|
||||
dt.H = time / 3600000 | 0;
|
||||
return minutes(dt, Math.abs(time) % 3600000);
|
||||
},
|
||||
days = function (dt, time) {
|
||||
dt.D = time / 86400000 | 0;
|
||||
return hours(dt, Math.abs(time) % 86400000);
|
||||
},
|
||||
format = function (dt, formatString) {
|
||||
var pattern = date.compile(formatString);
|
||||
var str = '';
|
||||
|
||||
for (var i = 1, len = pattern.length, token, value; i < len; i++) {
|
||||
token = pattern[i].charAt(0);
|
||||
if (token in dt) {
|
||||
value = '' + Math.abs(dt[token]);
|
||||
while (value.length < pattern[i].length) {
|
||||
value = '0' + value;
|
||||
}
|
||||
if (dt[token] < 0) {
|
||||
value = '-' + value;
|
||||
}
|
||||
str += value;
|
||||
} else {
|
||||
str += pattern[i].replace(/\[(.*)]/, '$1');
|
||||
}
|
||||
}
|
||||
return str;
|
||||
},
|
||||
delta = date1.getTime() - date2.getTime();
|
||||
|
||||
return {
|
||||
toMilliseconds: function (formatString) {
|
||||
return format(milliseconds({}, delta), formatString);
|
||||
},
|
||||
toSeconds: function (formatString) {
|
||||
return format(seconds({}, delta), formatString);
|
||||
},
|
||||
toMinutes: function (formatString) {
|
||||
return format(minutes({}, delta), formatString);
|
||||
},
|
||||
toHours: function (formatString) {
|
||||
return format(hours({}, delta), formatString);
|
||||
},
|
||||
toDays: function (formatString) {
|
||||
return format(days({}, delta), formatString);
|
||||
}
|
||||
};
|
||||
};
|
||||
var name = 'timespan';
|
||||
|
||||
date.plugin(name, { extender: { timeSpan: timeSpan } });
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve timespan
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var timeSpan = function (date1, date2) {
|
||||
var milliseconds = function (dt, time) {
|
||||
dt.S = time;
|
||||
return dt;
|
||||
},
|
||||
seconds = function (dt, time) {
|
||||
dt.s = time / 1000 | 0;
|
||||
return milliseconds(dt, Math.abs(time) % 1000);
|
||||
},
|
||||
minutes = function (dt, time) {
|
||||
dt.m = time / 60000 | 0;
|
||||
return seconds(dt, Math.abs(time) % 60000);
|
||||
},
|
||||
hours = function (dt, time) {
|
||||
dt.H = time / 3600000 | 0;
|
||||
return minutes(dt, Math.abs(time) % 3600000);
|
||||
},
|
||||
days = function (dt, time) {
|
||||
dt.D = time / 86400000 | 0;
|
||||
return hours(dt, Math.abs(time) % 86400000);
|
||||
},
|
||||
format = function (dt, formatString) {
|
||||
var pattern = date.compile(formatString);
|
||||
var str = '';
|
||||
|
||||
for (var i = 1, len = pattern.length, token, value; i < len; i++) {
|
||||
token = pattern[i].charAt(0);
|
||||
if (token in dt) {
|
||||
value = '' + Math.abs(dt[token]);
|
||||
while (value.length < pattern[i].length) {
|
||||
value = '0' + value;
|
||||
}
|
||||
if (dt[token] < 0) {
|
||||
value = '-' + value;
|
||||
}
|
||||
str += value;
|
||||
} else {
|
||||
str += pattern[i].replace(/\[(.*)]/, '$1');
|
||||
}
|
||||
}
|
||||
return str;
|
||||
},
|
||||
delta = date1.getTime() - date2.getTime();
|
||||
|
||||
return {
|
||||
toMilliseconds: function (formatString) {
|
||||
return format(milliseconds({}, delta), formatString);
|
||||
},
|
||||
toSeconds: function (formatString) {
|
||||
return format(seconds({}, delta), formatString);
|
||||
},
|
||||
toMinutes: function (formatString) {
|
||||
return format(minutes({}, delta), formatString);
|
||||
},
|
||||
toHours: function (formatString) {
|
||||
return format(hours({}, delta), formatString);
|
||||
},
|
||||
toDays: function (formatString) {
|
||||
return format(days({}, delta), formatString);
|
||||
}
|
||||
};
|
||||
};
|
||||
var name = 'timespan';
|
||||
|
||||
date.plugin(name, { extender: { timeSpan: timeSpan } });
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve timezone
|
||||
*/
|
||||
|
||||
var plugin = function (date, localized_date) {
|
||||
var options = {
|
||||
year: 'numeric', month: 'numeric', day: 'numeric',
|
||||
hour: 'numeric', minute: 'numeric', second: 'numeric'
|
||||
};
|
||||
var pattern = date.compile('M/D/Y, h:mm:ss A');
|
||||
var formatTZ = function (dateObj, arg, timeZone) {
|
||||
options.timeZone = 'UTC';
|
||||
var utcObj = date.parse(new Intl.DateTimeFormat('en-US', options).format(dateObj), pattern);
|
||||
|
||||
options.timeZone = timeZone;
|
||||
var dateObj2 = date.parse(new Intl.DateTimeFormat('en-US', options).format(dateObj), pattern);
|
||||
|
||||
var dateObj3 = date.addMilliseconds(dateObj2, dateObj.getMilliseconds());
|
||||
|
||||
dateObj3.getTimezoneOffset = function () { return (utcObj.getTime() - dateObj2.getTime()) / 60000 | 0; };
|
||||
return localized_date.format(dateObj3, arg);
|
||||
};
|
||||
var adjustments = [
|
||||
-60, -30, -20,
|
||||
0,
|
||||
60, 30, 20
|
||||
];
|
||||
var parseTZ = function (dateString, arg, timeZone) {
|
||||
var pattern2 = typeof arg === 'string' ? date.compile(arg) : arg;
|
||||
var dateObj = localized_date.parse(dateString, pattern2, true);
|
||||
|
||||
for (var i = 1, len = pattern2.length; i < len; i++) {
|
||||
if (pattern2[i].indexOf('Z') === 0) {
|
||||
return dateObj;
|
||||
}
|
||||
}
|
||||
|
||||
options.timeZone = timeZone;
|
||||
var dateTimeFormat = new Intl.DateTimeFormat('en-US', options);
|
||||
var dateObj2 = date.addMilliseconds(
|
||||
date.parse(dateTimeFormat.format(dateObj), pattern, true),
|
||||
dateObj.getMilliseconds()
|
||||
);
|
||||
var offset = dateObj.getTime() - dateObj2.getTime();
|
||||
var dateString2 = date.format(localized_date.parse(dateString, pattern2), pattern);
|
||||
|
||||
var comparer = function (d) {
|
||||
return dateString2 === dateTimeFormat.format(d);
|
||||
};
|
||||
|
||||
// Trying to adjust for daylight saving time.
|
||||
for (var j = 0, len2 = adjustments.length; j < len2; j++) {
|
||||
var d = date.addMilliseconds(dateObj, offset + adjustments[j] * 60000);
|
||||
if (comparer(d)) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return NaN;
|
||||
};
|
||||
|
||||
var name = 'timezone';
|
||||
|
||||
date.plugin(name, {
|
||||
extender: {
|
||||
formatTZ: formatTZ,
|
||||
parseTZ: parseTZ
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve timezone
|
||||
*/
|
||||
|
||||
var plugin = function (date, localized_date) {
|
||||
var options = {
|
||||
year: 'numeric', month: 'numeric', day: 'numeric',
|
||||
hour: 'numeric', minute: 'numeric', second: 'numeric'
|
||||
};
|
||||
var pattern = date.compile('M/D/Y, h:mm:ss A');
|
||||
var formatTZ = function (dateObj, arg, timeZone) {
|
||||
options.timeZone = 'UTC';
|
||||
var utcObj = date.parse(new Intl.DateTimeFormat('en-US', options).format(dateObj), pattern);
|
||||
|
||||
options.timeZone = timeZone;
|
||||
var dateObj2 = date.parse(new Intl.DateTimeFormat('en-US', options).format(dateObj), pattern);
|
||||
|
||||
var dateObj3 = date.addMilliseconds(dateObj2, dateObj.getMilliseconds());
|
||||
|
||||
dateObj3.getTimezoneOffset = function () { return (utcObj.getTime() - dateObj2.getTime()) / 60000 | 0; };
|
||||
return localized_date.format(dateObj3, arg);
|
||||
};
|
||||
var adjustments = [
|
||||
-60, -30, -20,
|
||||
0,
|
||||
60, 30, 20
|
||||
];
|
||||
var parseTZ = function (dateString, arg, timeZone) {
|
||||
var pattern2 = typeof arg === 'string' ? date.compile(arg) : arg;
|
||||
var dateObj = localized_date.parse(dateString, pattern2, true);
|
||||
|
||||
for (var i = 1, len = pattern2.length; i < len; i++) {
|
||||
if (pattern2[i].indexOf('Z') === 0) {
|
||||
return dateObj;
|
||||
}
|
||||
}
|
||||
|
||||
options.timeZone = timeZone;
|
||||
var dateTimeFormat = new Intl.DateTimeFormat('en-US', options);
|
||||
var dateObj2 = date.addMilliseconds(
|
||||
date.parse(dateTimeFormat.format(dateObj), pattern, true),
|
||||
dateObj.getMilliseconds()
|
||||
);
|
||||
var offset = dateObj.getTime() - dateObj2.getTime();
|
||||
var dateString2 = date.format(localized_date.parse(dateString, pattern2), pattern);
|
||||
|
||||
var comparer = function (d) {
|
||||
return dateString2 === dateTimeFormat.format(d);
|
||||
};
|
||||
|
||||
// Trying to adjust for daylight saving time.
|
||||
for (var j = 0, len2 = adjustments.length; j < len2; j++) {
|
||||
var d = date.addMilliseconds(dateObj, offset + adjustments[j] * 60000);
|
||||
if (comparer(d)) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return NaN;
|
||||
};
|
||||
|
||||
var name = 'timezone';
|
||||
|
||||
date.plugin(name, {
|
||||
extender: {
|
||||
formatTZ: formatTZ,
|
||||
parseTZ: parseTZ
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve two-digit-year
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'two-digit-year';
|
||||
|
||||
date.plugin(name, {
|
||||
parser: {
|
||||
YY: function (str) {
|
||||
var result = this.exec(/^\d\d/, str);
|
||||
result.value += result.value < 70 ? 2000 : 1900;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @preserve date-and-time.js plugin
|
||||
* @preserve two-digit-year
|
||||
*/
|
||||
|
||||
var plugin = function (date) {
|
||||
var name = 'two-digit-year';
|
||||
|
||||
date.plugin(name, {
|
||||
parser: {
|
||||
YY: function (str) {
|
||||
var result = this.exec(/^\d\d/, str);
|
||||
result.value += result.value < 70 ? 2000 : 1900;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return name;
|
||||
};
|
||||
|
||||
export { plugin as default };
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ar = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Arabic (ar)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var ar = function (date) {
|
||||
var code = 'ar';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],
|
||||
MMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],
|
||||
dddd: ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
|
||||
ddd: ['أحد', 'إثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
||||
dd: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
||||
A: ['ص', 'م']
|
||||
},
|
||||
formatter: {
|
||||
post: function (str) {
|
||||
var num = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
|
||||
return str.replace(/\d/g, function (i) {
|
||||
return num[i | 0];
|
||||
});
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
pre: function (str) {
|
||||
var map = { '٠': 0, '١': 1, '٢': 2, '٣': 3, '٤': 4, '٥': 5, '٦': 6, '٧': 7, '٨': 8, '٩': 9 };
|
||||
return str.replace(/[٠١٢٣٤٥٦٧٨٩]/g, function (i) {
|
||||
return '' + map[i];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return ar;
|
||||
|
||||
}));
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.az = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Azerbaijani (az)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var az = function (date) {
|
||||
var code = 'az';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['yanvar', 'fevral', 'mart', 'aprel', 'may', 'iyun', 'iyul', 'avqust', 'sentyabr', 'oktyabr', 'noyabr', 'dekabr'],
|
||||
MMM: ['yan', 'fev', 'mar', 'apr', 'may', 'iyn', 'iyl', 'avq', 'sen', 'okt', 'noy', 'dek'],
|
||||
dddd: ['Bazar', 'Bazar ertəsi', 'Çərşənbə axşamı', 'Çərşənbə', 'Cümə axşamı', 'Cümə', 'Şənbə'],
|
||||
ddd: ['Baz', 'BzE', 'ÇAx', 'Çər', 'CAx', 'Cüm', 'Şən'],
|
||||
dd: ['Bz', 'BE', 'ÇA', 'Çə', 'CA', 'Cü', 'Şə'],
|
||||
A: ['gecə', 'səhər', 'gündüz', 'axşam']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // gecə
|
||||
} else if (h < 12) {
|
||||
return this.res.A[1]; // səhər
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // gündüz
|
||||
}
|
||||
return this.res.A[3]; // axşam
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 2) {
|
||||
return h; // gecə, səhər
|
||||
}
|
||||
return h > 11 ? h : h + 12; // gündüz, axşam
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return az;
|
||||
|
||||
}));
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.bn = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Bengali (bn)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var bn = function (date) {
|
||||
var code = 'bn';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['জানুয়ারী', 'ফেবুয়ারী', 'মার্চ', 'এপ্রিল', 'মে', 'জুন', 'জুলাই', 'অগাস্ট', 'সেপ্টেম্বর', 'অক্টোবর', 'নভেম্বর', 'ডিসেম্বর'],
|
||||
MMM: ['জানু', 'ফেব', 'মার্চ', 'এপর', 'মে', 'জুন', 'জুল', 'অগ', 'সেপ্ট', 'অক্টো', 'নভ', 'ডিসেম্'],
|
||||
dddd: ['রবিবার', 'সোমবার', 'মঙ্গলবার', 'বুধবার', 'বৃহস্পত্তিবার', 'শুক্রবার', 'শনিবার'],
|
||||
ddd: ['রবি', 'সোম', 'মঙ্গল', 'বুধ', 'বৃহস্পত্তি', 'শুক্র', 'শনি'],
|
||||
dd: ['রব', 'সম', 'মঙ্গ', 'বু', 'ব্রিহ', 'শু', 'শনি'],
|
||||
A: ['রাত', 'সকাল', 'দুপুর', 'বিকাল']
|
||||
},
|
||||
formatter: {
|
||||
A: function (d) {
|
||||
var h = d.getHours();
|
||||
if (h < 4) {
|
||||
return this.res.A[0]; // রাত
|
||||
} else if (h < 10) {
|
||||
return this.res.A[1]; // সকাল
|
||||
} else if (h < 17) {
|
||||
return this.res.A[2]; // দুপুর
|
||||
} else if (h < 20) {
|
||||
return this.res.A[3]; // বিকাল
|
||||
}
|
||||
return this.res.A[0]; // রাত
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
h12: function (h, a) {
|
||||
if (a < 1) {
|
||||
return h < 4 || h > 11 ? h : h + 12; // রাত
|
||||
} else if (a < 2) {
|
||||
return h; // সকাল
|
||||
} else if (a < 3) {
|
||||
return h > 9 ? h : h + 12; // দুপুর
|
||||
}
|
||||
return h + 12; // বিকাল
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return bn;
|
||||
|
||||
}));
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.cs = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Czech (cs)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var cs = function (date) {
|
||||
var code = 'cs';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'],
|
||||
MMM: ['led', 'úno', 'bře', 'dub', 'kvě', 'čvn', 'čvc', 'srp', 'zář', 'říj', 'lis', 'pro'],
|
||||
dddd: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
|
||||
ddd: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
|
||||
dd: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return cs;
|
||||
|
||||
}));
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.de = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve German (de)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var de = function (date) {
|
||||
var code = 'de';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
||||
MMM: ['Jan.', 'Febr.', 'Mrz.', 'Apr.', 'Mai', 'Jun.', 'Jul.', 'Aug.', 'Sept.', 'Okt.', 'Nov.', 'Dez.'],
|
||||
dddd: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
|
||||
ddd: ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.'],
|
||||
dd: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
||||
A: ['Uhr nachmittags', 'Uhr morgens']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return de;
|
||||
|
||||
}));
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.dk = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Danish (DK)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var dk = function (date) {
|
||||
var code = 'dk';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'december'],
|
||||
MMM: ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
|
||||
dddd: ['søndag', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'],
|
||||
ddd: ['søn', 'man', 'tir', 'ons', 'tors', 'fre', 'lør'],
|
||||
dd: ['sø', 'ma', 'ti', 'on', 'to', 'fr', 'lø']
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return dk;
|
||||
|
||||
}));
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.el = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Greek (el)
|
||||
* @preserve It is using moment.js locale configuration as a reference.
|
||||
*/
|
||||
|
||||
var el = function (date) {
|
||||
var code = 'el';
|
||||
|
||||
date.locale(code, {
|
||||
res: {
|
||||
MMMM: [
|
||||
['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
|
||||
['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου']
|
||||
],
|
||||
MMM: ['Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μαϊ', 'Ιουν', 'Ιουλ', 'Αυγ', 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'],
|
||||
dddd: ['Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο'],
|
||||
ddd: ['Κυρ', 'Δευ', 'Τρι', 'Τετ', 'Πεμ', 'Παρ', 'Σαβ'],
|
||||
dd: ['Κυ', 'Δε', 'Τρ', 'Τε', 'Πε', 'Πα', 'Σα'],
|
||||
A: ['πμ', 'μμ']
|
||||
},
|
||||
formatter: {
|
||||
MMMM: function (d, formatString) {
|
||||
return this.res.MMMM[/D.*MMMM/.test(formatString) | 0][d.getMonth()];
|
||||
},
|
||||
hh: function (d) {
|
||||
return ('0' + d.getHours() % 12).slice(-2);
|
||||
},
|
||||
h: function (d) {
|
||||
return d.getHours() % 12;
|
||||
}
|
||||
},
|
||||
parser: {
|
||||
MMMM: function (str, formatString) {
|
||||
var result = this.find(this.res.MMMM[/D.*MMMM/.test(formatString) | 0], str);
|
||||
result.value++;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return code;
|
||||
};
|
||||
|
||||
return el;
|
||||
|
||||
}));
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.en = factory()));
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @preserve date-and-time.js locale configuration
|
||||
* @preserve Englis (en)
|
||||
* @preserve This is a dummy module.
|
||||
*/
|
||||
|
||||
var en = function (date) {
|
||||
var code = 'en';
|
||||
|
||||
return code;
|
||||
};
|
||||
|
||||
return en;
|
||||
|
||||
}));
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user