added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+127
View File
@@ -0,0 +1,127 @@
### Changelog
- 2.6.8 (2021-02-04)
- Bugfixes:
- Solve circular imports (#444)
- 2.6.6 (2020-08-23)
- Bugfixes:
- Fixed broken npm package (#417)
- 2.6.5 (2020-08-23)
- Bugfixes:
- `luxon`-less binary should not contain any `luxon` imports (#410)
- Fixed `toText` pluralization of “minutes“ (#415)
- 2.6.4 (2019-12-18)
- Bugfixes:
- Calculating series with unknown timezones will produce infinite loop (#320)
- Internal:
- Upgrade build dependencies
- 2.6.3 (2019-11-24)
- Features
- Allow passing `WeekdayStr` to `byweekday` like the types suggest is possible (#371)
- 2.6.2 (2019-06-08)
- Features
- Allow two digits for `BYDAY` (#330)
- Add a quick way to format `until` in `toText` (#313)
- Add support for parsing an rrule string without frequency (#339)
- Add getters for `rrules`, `exrules`, `rdates`, `exdates` (#347)
- 2.6.0 (2019-01-03)
- Bugfixes:
- Fix sourcemap structure (#303)
- 2.5.6 (2018-09-30)
- Bugfixes:
- Validate date inputs (#281)
- 2.5.5 (2018-09-06)
- Bugfixes:
- Don't emit `RDATE;TZID=UTC` for rdates
- 2.5.3 (2018-09-06)
- Bugfixes:
- Prevented emitting `DTSTART;TZID=UTC` when UTC is explicitly set as tzid
- 2.5.2 (2018-09-05)
- Bugfixes:
- Permitted RRuleSets with no rrules to have tzid
- 2.5.1 (2018-09-02)
- Bugfixes:
- Conformed output & parsing to RFC 5545 (#295)
- 2.4.1 (2018-08-16)
- Features:
- Added codecov (#265)
- Bugfixes:
- Fixed RRULE parsing issue (#266)
- 2.4.0 (2018-08-16)
- Features:
- Implement `TZID` support (#38, #261)
- Bugfixes:
- Fixed an error in Typescript output (#264)
- 2.3.6 (2018-08-14)
- Bugfixes:
- Point package.json to es5-compiled bundle (#260)
- 2.3.5 (2018-08-14)
- Features:
- Return text "every day" when all days are selected
- Bugfixes:
- Sort monthdays correctly from toText() (#101)
- Accept 0 as a valid monthday/weekday value (#153)
- Support 3-digit years (#202)
- 2.3.4 (2018-08-10)
- Fixed support for eastern hemisphere timezones (#247)
- 2.3.3 (2018-08-08)
- Fixed typescript error (#244)
- 2.3.2 (2018-08-07)
- Fixed deploy on npm (#239)
- 2.3.0 (2018-08-06)
- Converted to [Typescript](https://www.typescriptlang.org/) (#229)
- Add es5 and es6 distributions
- Fixed a bug where recurrences in DST were 1 hour off if the host system used DST (#233)
- Fixed numeric handling of weekday strings
- 2.2.8 (2018-02-16)
- Added `fromText()` and `toText()` support for rules with `RRule.MINUTELY` frequency.
- Added support for `VALUE=DATE` as a `RDATE` param.
- Added typescript definitions.
- Merged in the now obsolete `arolson101/rrule` fork (many thanks to @arolson101).
- Fixed `RRule` mutating passed-in `options` in some cases.
- Fixed unexpected results with dates lower than 1970.
- Fixed `RRule.DAILY` frequency when only 1 `BYHOUR` is provided.
- Fixed the internal `isLeapYear()` to only accept integers instead of relying on `instanceof` to check the parameter type.
- 2.2.0 (2017-03-11)
- Added support `RRuleSet`, which allows more complex recurrence setups,
mixing multiple rules, dates, exclusion rules, and exclusion dates.
- Added Millisecond precision
- Millisecond offset extracted from `dtstart` (`dtstart.getTime() % 1000`)
- Each recurrence is returned with the same offset
- Added some NLP support for hourly and byhour.
- Fixed export in nlp.js.
- 2.1.0
- Removed dependency on Underscore.js (thanks, @gsf).
- Various small bugfixes and improvements.
- 2.0.1
- Added bower.json.
- 2.0.0 (2013-07-16)
- Fixed a February 28-related issue.
- More flexible, backwards-incompatible API:
- `freq` is now `options.freq`.
- `options.cache` is now `noCache`.
- `iterator` has to return `true`
- `dtstart` and `options` arguments removed from `RRule.fromString`
(use `RRule.parseString` and modify `options` manually instead).
- `today` argument removed from `Rule.prototype.toText`
(never actually used).
- `rule.toString()` now includes `DTSTART` (if explicitly specified
in `options`).
- Day constants `.clone` is now `.nth`, eg. `RRule.FR.nth(-1)`
(last Friday).
- Added `RRule.parseString`
- Added `RRule.parseText`
- Added `RRule.optionsToString`
- 1.1.0 (2013-05-21)
- Added a [demo app](http://jakubroztocil.github.io/rrule/).
- Handle dates in `UNTIL` in `RRule.fromString`.
- Added support for RequireJS.
- Added `options` argument to `RRule.fromString`.
- 1.0.1 (2013-02-26)
- Fixed leap years (thanks @jessevogt)
- 1.0.0 (2013-01-24)
- Fixed timezone offset issues related to DST (thanks @evro).
- 1.0.0-beta (2012-08-15)
- Initial public release.
Generated Vendored
+65
View File
@@ -0,0 +1,65 @@
rrule.js: Library for working with recurrence rules for calendar dates.
=======================================================================
Copyright 2010, Jakub Roztocil <jakub@roztocil.name> and Lars Schöning
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of The author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
./rrule.js and ./test/tests.js is based on python-dateutil. LICENCE:
python-dateutil - Extensions to the standard Python datetime module.
====================================================================
Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
Copyright (c) 2012 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+827
View File
@@ -0,0 +1,827 @@
rrule.js
========
**Library for working with recurrence rules for calendar dates.**
[![NPM version][npm-image]][npm-url]
[![Build Status][ci-image]][ci-url]
[![js-standard-style][js-standard-image]][js-standard-url]
[![Downloads][downloads-image]][downloads-url]
[![Gitter][gitter-image]][gitter-url]
[![codecov.io](http://codecov.io/github/jakubroztocil/rrule/coverage.svg?branch=master)](http://codecov.io/github/jakubroztocil/rrule?branch=master)
rrule.js supports recurrence rules as defined in the [iCalendar
RFC](https://tools.ietf.org/html/rfc5545), with a few important
[differences](#differences-from-icalendar-rfc). It is a partial port of the
`rrule` module from the excellent
[python-dateutil](http://labix.org/python-dateutil/) library. On top of
that, it supports parsing and serialization of recurrence rules from and
to natural language.
* * * * *
### Quick Start
- [Demo app](http://jakubroztocil.github.io/rrule/)
#### Client Side
```bash
$ yarn add rrule
```
Alternatively, download manually:
* [rrule.min.js](https://jakubroztocil.github.io/rrule/dist/es5/rrule.min.js) (bundled, minified)
* [rrule.js](https://jakubroztocil.github.io/rrule/dist/es5/rrule.js) (bundled, not minified)
* [rrule-tz.min.js](https://jakubroztocil.github.io/rrule/dist/es5/rrule-tz.min.js) (with timezone support, bundled, minified)
* [rrule-tz.js](https://jakubroztocil.github.io/rrule/dist/es5/rrule-tz.js) (with timezone support, bundled, not minified)
```html
<script src="rrule/dist/es5/rrule.min.js"></script>
```
#### Server Side
Includes optional TypeScript types
```bash
$ yarn add rrule
# or
$ npm install rrule
```
#### Usage
**RRule:**
```es6
import { RRule, RRuleSet, rrulestr } from 'rrule'
// Create a rule:
const rule = new RRule({
freq: RRule.WEEKLY,
interval: 5,
byweekday: [RRule.MO, RRule.FR],
dtstart: new Date(Date.UTC(2012, 1, 1, 10, 30)),
until: new Date(Date.UTC(2012, 12, 31))
})
// Get all occurrence dates (Date instances):
rule.all()
[ '2012-02-03T10:30:00.000Z',
'2012-03-05T10:30:00.000Z',
'2012-03-09T10:30:00.000Z',
'2012-04-09T10:30:00.000Z',
'2012-04-13T10:30:00.000Z',
'2012-05-14T10:30:00.000Z',
'2012-05-18T10:30:00.000Z',
/* … */]
// Get a slice:
rule.between(new Date(Date.UTC(2012, 7, 1)), new Date(Date.UTC(2012, 8, 1)))
['2012-08-27T10:30:00.000Z',
'2012-08-31T10:30:00.000Z']
// Get an iCalendar RRULE string representation:
// The output can be used with RRule.fromString().
rule.toString()
"DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR"
// Get a human-friendly text representation:
// The output can be used with RRule.fromText().
rule.toText()
"every 5 weeks on Monday, Friday until January 31, 2013"
```
**RRuleSet:**
```js
const rruleSet = new RRuleSet()
// Add a rrule to rruleSet
rruleSet.rrule(new RRule({
freq: RRule.MONTHLY,
count: 5,
dtstart: new Date(Date.UTC(2012, 1, 1, 10, 30))
}))
// Add a date to rruleSet
rruleSet.rdate(new Date(Date.UTC(2012, 6, 1, 10, 30)))
// Add another date to rruleSet
rruleSet.rdate(new Date(Date.UTC(2012, 6, 2, 10, 30)))
// Add a exclusion rrule to rruleSet
rruleSet.exrule(new RRule({
freq: RRule.MONTHLY,
count: 2,
dtstart: new Date(Date.UTC(2012, 2, 1, 10, 30))
}))
// Add a exclusion date to rruleSet
rruleSet.exdate(new Date(Date.UTC(2012, 5, 1, 10, 30)))
// Get all occurrence dates (Date instances):
rruleSet.all()
[ '2012-02-01T10:30:00.000Z',
'2012-05-01T10:30:00.000Z',
'2012-07-01T10:30:00.000Z',
'2012-07-02T10:30:00.000Z' ]
// Get a slice:
rruleSet.between(new Date(Date.UTC(2012, 2, 1)), new Date(Date.UTC(2012, 6, 2)))
[ '2012-05-01T10:30:00.000Z', '2012-07-01T10:30:00.000Z' ]
// To string
rruleSet.valueOf()
['DTSTART:20120201T023000Z',
'RRULE:FREQ=MONTHLY;COUNT=5',
'RDATE:20120701T023000Z,20120702T023000Z',
'EXRULE:FREQ=MONTHLY;COUNT=2',
'EXDATE:20120601T023000Z']
// To string
rruleSet.toString()
'["DTSTART:20120201T023000Z","RRULE:FREQ=MONTHLY;COUNT=5","RDATE:20120701T023000Z,20120702T023000Z","EXRULE:FREQ=MONTHLY;COUNT=2","EXDATE:20120601T023000Z"]'
```
**rrulestr:**
```js
// Parse a RRule string, return a RRule object
rrulestr('DTSTART:20120201T023000Z\nRRULE:FREQ=MONTHLY;COUNT=5')
// Parse a RRule string, return a RRuleSet object
rrulestr('DTSTART:20120201T023000Z\nRRULE:FREQ=MONTHLY;COUNT=5', {forceset: true})
// Parse a RRuleSet string, return a RRuleSet object
rrulestr('DTSTART:20120201T023000Z\nRRULE:FREQ=MONTHLY;COUNT=5\nRDATE:20120701T023000Z,20120702T023000Z\nEXRULE:FREQ=MONTHLY;COUNT=2\nEXDATE:20120601T023000Z')
```
### Important: Use UTC dates
Dates in JavaScript are tricky. `RRule` tries to support as much flexibility as possible without adding any large required 3rd party dependencies, but that means we also have some special rules.
By default, `RRule` deals in ["floating" times or UTC timezones](https://tools.ietf.org/html/rfc5545#section-3.2.19). If you want results in a specific timezone, `RRule` also provides [timezone support](#timezone-support). Either way, JavaScript's built-in "timezone" offset tends to just get in the way, so this library simply doesn't use it at all. All times are returned with zero offset, as though it didn't exist in JavaScript.
**The bottom line is the returned "UTC" dates are always meant to be interpreted as dates in your local timezone. This may mean you have to do additional conversion to get the "correct" local time with offset applied.**
For this reason, it is highly recommended to use timestamps in UTC eg. `new Date(Date.UTC(...))`. Returned dates will likewise be in UTC (except on Chrome, which always returns dates with a timezone offset).
For example:
```ts
// local machine zone is America/Los_Angeles
const rule = RRule.fromString(
"DTSTART;TZID=America/Denver:20181101T190000;\n"
+ "RRULE:FREQ=WEEKLY;BYDAY=MO,WE,TH;INTERVAL=1;COUNT=3"
)
rule.all()
[ 2018-11-01T18:00:00.000Z,
2018-11-05T18:00:00.000Z,
2018-11-07T18:00:00.000Z ]
// Even though the given offset is `Z` (UTC), these are local times, not UTC times.
// Each of these this is the correct local Pacific time of each recurrence in
// America/Los_Angeles when it is 19:00 in America/Denver, including the DST shift.
// You can get the local components by using the getUTC* methods eg:
date.getUTCDate() // --> 1
date.getUTCHours() // --> 18
```
If you want to get the same times in true UTC, you may do so eg. using Luxon:
```ts
rule.all().map(date =>
DateTime.fromJSDate(date)
.toUTC()
.setZone('local', { keepLocalTime: true })
.toJSDate()
)
[ 2018-11-02T01:00:00.000Z,
2018-11-06T02:00:00.000Z,
2018-11-08T02:00:00.000Z ]
// These times are in true UTC; you can see the hours shift
```
For more examples see
[python-dateutil](http://labix.org/python-dateutil/) documentation.
* * * * *
### Timezone Support
Optionally, it also supports use of the `TZID` parameter in the
[RFC](https://tools.ietf.org/html/rfc5545#section-3.2.19)
when the [Luxon](https://github.com/moment/luxon) library is provided. The
[specification](https://moment.github.io/luxon/docs/manual/zones.html#specifying-a-zone)
and [support matrix](https://moment.github.io/luxon/docs/manual/matrix.html) for Luxon apply.
Example with `TZID`:
```js
new RRule({
dtstart: new Date(Date.UTC(2018, 1, 1, 10, 30)),
count: 1,
tzid: 'Asia/Tokyo'
}).all()
// assuming the system timezone is set to America/Los_Angeles, you get:
[ '2018-01-31T17:30:00.000Z' ]
// which is the time in Los Angeles when it's 2018-02-01T10:30:00 in Tokyo.
```
Whether or not you use the `TZID` param, make sure to only use JS `Date` objects that are
represented in UTC to avoid unexpected timezone offsets being applied, for example:
```js
// WRONG: Will produce dates with TZ offsets added
new RRule({
freq: RRule.MONTHLY,
dtstart: new Date(2018, 1, 1, 10, 30),
until: new Date(2018, 2, 31)
}).all()
[ '2018-02-01T18:30:00.000Z', '2018-03-01T18:30:00.000Z' ]
// RIGHT: Will produce dates with recurrences at the correct time
new RRule({
freq: RRule.MONTHLY,
dtstart: new Date(Date.UTC(2018, 1, 1, 10, 30)),
until: new Date(Date.UTC(2018, 2, 31))
}).all()
[ '2018-02-01T10:30:00.000Z', '2018-03-01T10:30:00.000Z' ]
```
### API
#### `RRule` Constructor
```javascript
new RRule(options[, noCache=false])
```
The `options` argument mostly corresponds to the properties defined for `RRULE` in the
iCalendar RFC. Only `freq` is required.
<table>
<!-- why, markdown... -->
<thead>
<tr>
<th>Option</th>
<th>Description</th>
</tr>
<thead>
<tbody>
<tr>
<td><code>freq</code></td>
<td>
<p>(required) One of the following constants:</p>
<ul>
<li><code>RRule.YEARLY</code></li>
<li><code>RRule.MONTHLY</code></li>
<li><code>RRule.WEEKLY</code></li>
<li><code>RRule.DAILY</code></li>
<li><code>RRule.HOURLY</code></li>
<li><code>RRule.MINUTELY</code></li>
<li><code>RRule.SECONDLY</code></li>
</ul>
</td>
</tr>
<tr>
<td><code>dtstart</code></td>
<td>The recurrence start. Besides being the base for the
recurrence, missing parameters in the final recurrence
instances will also be extracted from this date. If not
given, <code>new Date</code> will be used instead.
**IMPORTANT:** See the discussion under <a href="#timezone-support">timezone support</a>
</td>
</tr>
<tr>
<td><code>interval</code></td>
<td>The interval between each freq iteration. For example,
when using <code>RRule.YEARLY</code>, an interval of <code>2</code> means
once every
two years, but with <code>RRule.HOURLY</code>, it means once every two
hours.
The default interval is <code>1</code>.
</td>
</tr>
<tr>
<td><code>wkst</code></td>
<td>The week start day. Must be one of the <code>RRule.MO</code>,
<code>RRule.TU</code>, <code>RRule.WE</code> constants, or an integer,
specifying
the first day of the week. This will affect recurrences based
on weekly periods. The default week start is <code>RRule.MO</code>.
</td>
</tr>
<tr>
<td><code>count</code></td>
<td>How many occurrences will be generated.</td>
</tr>
<tr>
<td><code>until</code></td>
<td>If given, this must be a <code>Date</code> instance, that will specify
the limit of the recurrence. If a recurrence instance happens
to be the same as the <code>Date</code> instance given in the
<code>until</code>
argument, this will be the last occurrence.
</td>
</tr>
<tr>
<td><code>tzid</code></td>
<td>If given, this must be a string <a href="https://moment.github.io/luxon/docs/manual/zones.html#specifying-a-zone">supported</a>
by Luxon, and the <a href="https://moment.github.io/luxon/">Luxon</a> library must be provided. See
discussion under <a href="#timezone-support">Timezone support</a>.
</td>
</tr>
<tr>
<td><code>bysetpos</code></td>
<td>If given, it must be either an integer, or an array of
integers, positive or negative. Each given integer will specify
an occurrence number, corresponding to the nth occurrence of
the rule inside the frequency period. For example, a
<code>bysetpos</code> of <code>-1</code> if combined with a <code>RRule.MONTHLY</code>
frequency, and a byweekday of (<code>RRule.MO</code>, <code>RRule.TU</code>,
<code>RRule.WE</code>, <code>RRule.TH</code>, <code>RRule.FR</code>), will result in
the last
work day of every month.
</td>
</tr>
<tr>
<td><code>bymonth</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the months to apply the recurrence to.
</td>
</tr>
<tr>
<td><code>bymonthday</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the month days to apply the recurrence to.
</td>
</tr>
<tr>
<td><code>byyearday</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the year days to apply the recurrence to.
</td>
</tr>
<tr>
<td><code>byweekno</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the week numbers to apply the recurrence to.
Week numbers have the meaning described in ISO8601, that is,
the first week of the year is that containing at least four
days of the new year.
</td>
</tr>
<tr>
<td><code>byweekday</code></td>
<td>If given, it must be either an integer (<code>0 == RRule.MO</code>), an
array of integers, one of the weekday constants
(<code>RRule.MO</code>,
<code>RRule.TU</code>, etc), or an array of these constants. When
given,
these variables will define the weekdays where the recurrence
will be applied. It's also possible to use an argument n for
the weekday instances, which will mean the nth occurrence of
this weekday in the period. For example, with
<code>RRule.MONTHLY</code>,
or with <code>RRule.YEARLY</code> and <code>BYMONTH</code>, using
<code>RRule.FR.nth(+1)</code> or <code>RRule.FR.nth(-1)</code> in <code>byweekday</code>
will specify the first or last friday of the month where the
recurrence happens.
Notice
that the RFC documentation, this is specified as <code>BYDAY</code>,
but was renamed to avoid the ambiguity of that argument.
</td>
</tr>
<tr>
<td><code>byhour</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the hours to apply the recurrence to.
</td>
</tr>
<tr>
<td><code>byminute</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the minutes to apply the recurrence to.
</td>
</tr>
<tr>
<td><code>bysecond</code></td>
<td>If given, it must be either an integer, or an array of
integers, meaning the seconds to apply the recurrence to.
</td>
</tr>
<tr>
<td><code>byeaster</code></td>
<td>This is an extension to the RFC specification which the Python
implementation provides.
<strong>Not implemented in the JavaScript version.</strong>
</td>
</tr>
</tbody>
</table>
`noCache`: Set to `true` to disable caching of results. If you will use the
same rrule instance multiple times, enabling caching will improve the
performance considerably. Enabled by default.
See also [python-dateutil](http://labix.org/python-dateutil/)
documentation.
* * * * *
#### Instance properties
<dl>
<dt><code>rule.options</code></dt>
<dd>Processed options applied to the rule. Includes default options
(such us <code>wkstart</code>). Currently,
<code>rule.options.byweekday</code> isn't equal
to <code>rule.origOptions.byweekday</code> (which is an inconsistency).
</dd>
<dt><code>rule.origOptions</code></dt>
<dd>The original <code>options</code> argument passed to
the constructor.</dd>
</dl>
* * * * *
#### Occurrence Retrieval Methods
##### `RRule.prototype.all([iterator])`
Returns all dates matching the rule. It is a replacement for the
iterator protocol this class implements in the Python version.
As rules without `until` or `count` represent infinite date series, you
can optionally pass `iterator`, which is a function that is called for
each date matched by the rule. It gets two parameters `date` (the `Date`
instance being added), and `i` (zero-indexed position of `date` in the
result). Dates are being added to the result as long as the iterator
returns `true`. If a `false`-y value is returned, `date` isn't added to
the result and the iteration is interrupted (possibly prematurely).
```javascript
rule.all()
[ '2012-02-01T10:30:00.000Z',
'2012-05-01T10:30:00.000Z',
'2012-07-01T10:30:00.000Z',
'2012-07-02T10:30:00.000Z' ]
rule.all(function (date, i){return i < 2})
[ '2012-02-01T10:30:00.000Z',
'2012-05-01T10:30:00.000Z' ]
```
##### `RRule.prototype.between(after, before, inc=false [, iterator])`
Returns all the occurrences of the rrule between `after` and `before`.
The inc keyword defines what happens if `after` and/or `before` are
themselves occurrences. With `inc == true`, they will be included in the
list, if they are found in the recurrence set.
Optional `iterator` has the same function as it has with
`RRule.prototype.all()`.
```javascript
rule.between(new Date(Date.UTC(2012, 7, 1)), new Date(Date.UTC(2012, 8, 1)))
['2012-08-27T10:30:00.000Z',
'2012-08-31T10:30:00.000Z']
```
##### `RRule.prototype.before(dt, inc=false)`
Returns the last recurrence before the given `Date` instance. The `inc`
argument defines what happens if `dt` is an occurrence. With
`inc == true`, if `dt` itself is an occurrence, it will be returned.
##### `RRule.prototype.after(dt, inc=false)`
Returns the first recurrence
after the given `Date` instance. The `inc` argument defines what happens
if `dt` is an occurrence. With `inc == true`, if `dt` itself is an
occurrence, it will be returned.
See also [python-dateutil](http://labix.org/python-dateutil/)
documentation.
* * * * *
#### iCalendar RFC String Methods
##### `RRule.prototype.toString()`
Returns a string representation of the rule as per the iCalendar RFC.
Only properties explicitly specified in `options` are included:
```javascript
rule.toString()
"DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR"
rule.toString() == RRule.optionsToString(rule.origOptions)
true
```
##### `RRule.optionsToString(options)`
Converts `options` to iCalendar RFC `RRULE` string:
```javascript
// Get full a string representation of all options,
// including the default and inferred ones.
RRule.optionsToString(rule.options)
"DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;WKST=0;UNTIL=20130130T230000Z;BYDAY=MO,FR;BYHOUR=10;BYMINUTE=30;BYSECOND=0"
// Cherry-pick only some options from an rrule:
RRule.optionsToString({
freq: rule.options.freq,
dtstart: rule.options.dtstart
})
"DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;"
```
##### `RRule.fromString(rfcString)`
Constructs an `RRule` instance from a complete `rfcString`:
```javascript
var rule = RRule.fromString("DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;")
// This is equivalent
var rule = new RRule(RRule.parseString("DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY"))
```
##### `RRule.parseString(rfcString)`
Only parse RFC string and return `options`.
```javascript
var options = RRule.parseString('FREQ=DAILY;INTERVAL=6')
options.dtstart = new Date(Date.UTC(2000, 1, 1))
var rule = new RRule(options)
```
* * * * *
#### Natural Language Text Methods
These methods provide an incomplete support for text–`RRule` and
`RRule`–text conversion. You should test them with your input to see
whether the result is acceptable.
##### `RRule.prototype.toText([gettext, [language]])`
Returns a textual representation of `rule`. The `gettext` callback, if
provided, will be called for each text token and its return value used
instead. The optional `language` argument is a language definition to be
used (defaults to `rrule/nlp.js:ENGLISH`).
```javascript
var rule = new RRule({
freq: RRule.WEEKLY,
count: 23
})
rule.toText()
"every week for 23 times"
```
##### `RRule.prototype.isFullyConvertibleToText()`
Provides a hint on whether all the options the rule has are convertible
to text.
##### `RRule.fromText(text[, language])`
Constructs an `RRule` instance from `text`.
```javascript
rule = RRule.fromText('every day for 3 times')
```
##### `RRule.parseText(text[, language])`
Parse `text` into `options`:
```javascript
options = RRule.parseText('every day for 3 times')
// {freq: 3, count: "3"}
options.dtstart = new Date(Date.UTC(2000, 1, 1))
var rule = new RRule(options)
```
* * * * *
#### `RRuleSet` Constructor
```javascript
new RRuleSet([noCache=false])
```
The RRuleSet instance allows more complex recurrence setups, mixing multiple
rules, dates, exclusion rules, and exclusion dates.
Default `noCache` argument is `false`, caching of results will be enabled,
improving performance of multiple queries considerably.
##### `RRuleSet.prototype.rrule(rrule)`
Include the given rrule instance in the recurrence set generation.
##### `RRuleSet.prototype.rdate(dt)`
Include the given datetime instance in the recurrence set generation.
##### `RRuleSet.prototype.exrule(rrule)`
Include the given rrule instance in the recurrence set exclusion list. Dates
which are part of the given recurrence rules will not be generated, even if
some inclusive rrule or rdate matches them. NOTE: EXRULE has been (deprecated
in RFC 5545)[https://icalendar.org/iCalendar-RFC-5545/a-3-deprecated-features.html]
and does not support a DTSTART property.
##### `RRuleSet.prototype.exdate(dt)`
Include the given datetime instance in the recurrence set exclusion list. Dates
included that way will not be generated, even if some inclusive rrule or
rdate matches them.
##### `RRuleSet.prototype.tzid(tz?)`
Sets or overrides the timezone identifier. Useful if there are no rrules in this
RRuleSet and thus no DTSTART.
##### `RRuleSet.prototype.all([iterator])`
Same as `RRule.prototype.all`.
##### `RRuleSet.prototype.between(after, before, inc=false [, iterator])`
Same as `RRule.prototype.between`.
##### `RRuleSet.prototype.before(dt, inc=false)`
Same as `RRule.prototype.before`.
##### `RRuleSet.prototype.after(dt, inc=false)`
Same as `RRule.prototype.after`.
##### `RRuleSet.prototype.rrules()`
Get list of included rrules in this recurrence set.
##### `RRuleSet.prototype.exrules()`
Get list of excluded rrules in this recurrence set.
##### `RRuleSet.prototype.rdates()`
Get list of included datetimes in this recurrence set.
##### `RRuleSet.prototype.exdates()`
Get list of excluded datetimes in this recurrence set.
* * * * *
#### `rrulestr` Function
```js
rrulestr(rruleStr[, options])
```
The `rrulestr` function is a parser for RFC-like syntaxes. The string passed
as parameter may be a multiple line string, a single line string, or just the
RRULE property value.
Additionally, it accepts the following keyword arguments:
`cache`
If True, the rruleset or rrule created instance will cache its results.
Default is not to cache.
`dtstart`
If given, it must be a datetime instance that will be used when no DTSTART
property is found in the parsed string. If it is not given, and the property
is not found, datetime.now() will be used instead.
`unfold`
If set to True, lines will be unfolded following the RFC specification. It
defaults to False, meaning that spaces before every line will be stripped.
`forceset`
If set to True a rruleset instance will be returned, even if only a single rule
is found. The default is to return an rrule if possible, and an rruleset if necessary.
`compatible`
If set to True, the parser will operate in RFC-compatible mode. Right now it
means that unfold will be turned on, and if a DTSTART is found, it will be
considered the first recurrence instance, as documented in the RFC.
`tzid`
If given, it must be a string that will be used when no `TZID` property is found
in the parsed string. If it is not given, and the property is not found, `'UTC'`
will be used by default.
* * * * *
### Differences From iCalendar RFC
* `RRule` has no `byday` keyword. The equivalent keyword has been replaced by
the `byweekday` keyword, to remove the ambiguity present in the original
keyword.
* Unlike documented in the RFC, the starting datetime, `dtstart`, is
not the first recurrence instance, unless it does fit in the specified rules.
This is in part due to this project being a port of
[python-dateutil](https://labix.org/python-dateutil#head-a65103993a21b717f6702063f3717e6e75b4ba66),
which has the same non-compliant functionality. Note that you can get the
original behavior by using a `RRuleSet` and adding the `dtstart` as an `rdate`.
```javascript
var rruleSet = new RRuleSet()
var start = new Date(Date.UTC(2012, 1, 1, 10, 30))
// Add a rrule to rruleSet
rruleSet.rrule(new RRule({
freq: RRule.MONTHLY,
count: 5,
dtstart: start
}))
// Add a date to rruleSet
rruleSet.rdate(start)
```
* Unlike documented in the RFC, every keyword is valid on every frequency (the
RFC documents that `byweekno` is only valid on yearly frequencies, for example).
### Development
rrule.js is implemented in Typescript. It uses [JavaScript Standard Style](https://github.com/feross/standard) coding style.
To run the code, checkout this repository and run:
```
$ yarn
```
To run the tests, run:
```
$ yarn test
```
To build files for distribution, run:
```
$ yarn build
```
#### Authors
* [Jakub Roztocil](http://roztocil.co/)
([@jakubroztocil](http://twitter.com/jakubroztocil))
* Lars Schöning ([@lyschoening](http://twitter.com/lyschoening))
* David Golightly ([@davigoli](http://twitter.com/davigoli))
Python `dateutil` is written by [Gustavo
Niemeyer](http://niemeyer.net/).
See [LICENCE](https://github.com/jakubroztocil/rrule/blob/master/LICENCE) for
more details.
[npm-url]: https://npmjs.org/package/rrule
[npm-image]: http://img.shields.io/npm/v/rrule.svg
[ci-url]: https://github.com/jakubroztocil/rrule/actions
[ci-image]: https://github.com/jakubroztocil/rrule/workflows/Node%20CI/badge.svg
[downloads-url]: https://npmjs.org/package/rrule
[downloads-image]: http://img.shields.io/npm/dm/rrule.svg?style=flat-square
[js-standard-url]: https://github.com/feross/standard
[js-standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat
[gitter-url]: https://gitter.im/rrule-js/Lobby
[gitter-image]: https://img.shields.io/gitter/room/nwjs/nw.js.svg
#### Related projects
* https://rrules.com/ — RESTful API to get back occurrences of RRULEs that conform to RFC 5545.
+12011
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+39
View File
File diff suppressed because one or more lines are too long
+3746
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+39
View File
File diff suppressed because one or more lines are too long
+207
View File
@@ -0,0 +1,207 @@
body {
font: 14px/1.4 sans-serif;
color: #111;
background: #fafafa;
}
a {
color: #366097;
}
h2, h1 {
text-align: center;
font-family: georgia, serif;
font-size: 3em;
font-weight: normal;
}
h2 {
font-size: 2.5em;
margin-bottom: .7em;
}
pre, ol {
margin: 0
}
table {
border-collapse: collapse;
width: 100%;
}
table, td, th {
border: 1px solid #fafafa;
}
td, th {
padding: .4em;
}
tbody th {
text-align: right;
width: 10em;
}
code, label {
background: #fff;
border-radius: .3em;
padding: .2em .3em;
border: 1px solid #ededed;
}
label {
white-space: nowrap;
display: inline-block;
margin: 0 .3em .3em 0;
cursor: pointer;
font-size: .9em;
}
input:not([type=checkbox]):not([type=radio]), select {
width: 100%;
font-size: 1.4em;
box-sizing: border-box;
}
input {
padding: .2em;
}
.error {
color: red;
}
#page {
min-width: 960px;
margin: auto;
}
#intro {
text-align: center;
font-size: 1.2em;
}
/* Input
-------------------------------------- */
#tabs {
border-bottom: 1px solid #111;
text-align: center;
}
#tabs a {
background: #111;
border: 1px solid #111;
padding: .4em 1em;
margin: 0 .5em -1px;
color: #eee;
display: inline-block;
text-decoration: none;
font-weight: bold;
font-size: 1.1em;
border-top-left-radius: .2em;
border-top-right-radius: .2em;
}
#tabs a.active {
color: #111;
background: #fafafa;
border-bottom-color: #fafafa;
}
#input {
float: left;
width: 40%
}
#input th {
width: 7em !important;
}
#input section {
padding: 1em;
}
.examples li {
margin-bottom: .7em;
}
.examples code {
cursor: pointer;
}
#rfc-input input {
font-family: monospace;
}
#options-input input, #options-input select {
font-size: 1em;
}
.option-name {
position: relative;
cursor: help;
}
.option-name .help {
border-radius: .3em;
font-weight: normal;
display: none;
position: absolute;
padding: 1em;
background: #333;
color: #fafafa;
border: 1px solid #000;
left: 110%;
right: -100%;
width: 350px;
text-align: left;
top: -1em;
box-shadow: 3px 3px 3px #888;
line-height: 1.6;
font-size: .9em;
}
.option-name .help code {
color: #fff;
background: #000;
}
.option-name:hover code:first-child{
background: #222;
color: #fafafa;
}
.option-name:hover .help {
display: block;
}
/* Output
-------------------------------------- */
#output {
float: right;
width: 58%
}
#output pre {
white-space: pre-wrap;
}
#output td {
background: #fff;
}
#output td, #output th {
vertical-align: top;
}
#output li {
font-family: monospace;
}
#output li:nth-child(even) {
background: #f1f1f1;
}
#dates {
font-size: .9em;
}
#dates td:first-child {
color: #ccc;
}
#dates td:first-child {
text-align: right;
}
#dates td.b {
background: #eaeaea;
}
#dates td.b {
background: #f0f0f0;
}
#output a {
color: inherit
}
+2
View File
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=demo.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../../demo/demo.ts"],"names":[],"mappings":""}
+50
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+586
View File
@@ -0,0 +1,586 @@
<!doctype html>
<!-- GitHub pages homepage -->
<html>
<head>
<title>rrule.js demo</title>
<link rel="stylesheet" href="./dist/demo.css" />
<script type="text/javascript" src="./dist/demo.js"></script>
</head>
<body>
<div id="page">
<p>
<a href="https://github.com/jakubroztocil/rrule">Code and docs</a>
</p>
<h1>
<code>rrule.js</code> demo</h1>
<section id="intro">
<p>
This is a demo and test app for
<code>rrule.js</code>, a JavaScript library for working with recurrence rules for calendar dates.
</p>
</section>
<section id="output">
<h2>Output</h2>
<table>
<tr>
<th>
<code>rule =</code>
</th>
<td>
<pre id="init"></pre>
</td>
</tr>
<tr>
<th>
<code>rule.origOptions</code>
</th>
<td>
<pre id="options-output"></pre>
</td>
</tr>
<tr>
<th>
<code>rule.toString()</code>
</th>
<td>
<pre id="rfc-output"><a href=""></a></pre>
</td>
</tr>
<tr>
<th>
<code>rule.toText()</code>
</th>
<td>
<em id="text-output">
<a href=""></a>
</em>
</td>
</tr>
<tr>
<th>
<code>rule.all()</code>
</th>
<td>
<table id="dates"></table>
</td>
</tr>
</table>
</section>
<div id="input">
<h2>Input</h2>
<div id="tabs"></div>
<div id="input-types">
<section id="options-input">
<h3>Options</h3>
<form>
<table>
<tbody>
<tr>
<th>
<div class="option-name">
<code>freq</code>
<div class="help">Frequency</div>
</div>
</th>
<td>
<label>
<input name="freq" type="radio" value="0" />RRule.YEARLY</label>
<label>
<input name="freq" type="radio" value="1" />RRule.MONTHLY</label>
<label>
<input name="freq" type="radio" value="2" checked />RRule.WEEKLY</label>
<label>
<input name="freq" type="radio" value="3" />RRule.DAILY</label>
<label>
<input name="freq" type="radio" value="4" />RRule.HOURLY</label>
<label>
<input name="freq" type="radio" value="5" />RRule.MINUTELY</label>
<label>
<input name="freq" type="radio" value="6" />RRule.SECONDLY</label>
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>dtstart</code>
<div class="help">The recurrence start. Besides being the base for the recurrence, missing parameters in the final recurrence
instances will also be extracted from this date. If not given,
<code>new Date</code> will be used instead.
</div>
</div>
</th>
<td>
<input name="dtstart" type="datetime-local" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>tzid</code>
<div class="help">The timezone for the rule. If present, all recurrences will be interpreted as being in the local time
of the given timezone. If not present, <code>UTC</code> will be used instead.
</div>
</div>
</th>
<td>
<select name="tzid">
<option value="">none (UTC)</option>
<option value="Pacific/Midway">(GMT-11:00) Midway Island, Samoa</option>
<option value="America/Adak">(GMT-10:00) Hawaii-Aleutian</option>
<option value="Etc/GMT+10">(GMT-10:00) Hawaii</option>
<option value="Pacific/Marquesas">(GMT-09:30) Marquesas Islands</option>
<option value="Pacific/Gambier">(GMT-09:00) Gambier Islands</option>
<option value="America/Anchorage">(GMT-09:00) Alaska</option>
<option value="America/Ensenada">(GMT-08:00) Tijuana, Baja California</option>
<option value="Etc/GMT+8">(GMT-08:00) Pitcairn Islands</option>
<option value="America/Los_Angeles">(GMT-08:00) Pacific Time (US & Canada)</option>
<option value="America/Denver">(GMT-07:00) Mountain Time (US & Canada)</option>
<option value="America/Chihuahua">(GMT-07:00) Chihuahua, La Paz, Mazatlan</option>
<option value="America/Dawson_Creek">(GMT-07:00) Arizona</option>
<option value="America/Belize">(GMT-06:00) Saskatchewan, Central America</option>
<option value="America/Cancun">(GMT-06:00) Guadalajara, Mexico City, Monterrey</option>
<option value="Chile/EasterIsland">(GMT-06:00) Easter Island</option>
<option value="America/Chicago">(GMT-06:00) Central Time (US & Canada)</option>
<option value="America/New_York">(GMT-05:00) Eastern Time (US & Canada)</option>
<option value="America/Havana">(GMT-05:00) Cuba</option>
<option value="America/Bogota">(GMT-05:00) Bogota, Lima, Quito, Rio Branco</option>
<option value="America/Caracas">(GMT-04:30) Caracas</option>
<option value="America/Santiago">(GMT-04:00) Santiago</option>
<option value="America/La_Paz">(GMT-04:00) La Paz</option>
<option value="Atlantic/Stanley">(GMT-04:00) Faukland Islands</option>
<option value="America/Campo_Grande">(GMT-04:00) Brazil</option>
<option value="America/Goose_Bay">(GMT-04:00) Atlantic Time (Goose Bay)</option>
<option value="America/Glace_Bay">(GMT-04:00) Atlantic Time (Canada)</option>
<option value="America/St_Johns">(GMT-03:30) Newfoundland</option>
<option value="America/Araguaina">(GMT-03:00) UTC-3</option>
<option value="America/Montevideo">(GMT-03:00) Montevideo</option>
<option value="America/Miquelon">(GMT-03:00) Miquelon, St. Pierre</option>
<option value="America/Godthab">(GMT-03:00) Greenland</option>
<option value="America/Argentina/Buenos_Aires">(GMT-03:00) Buenos Aires</option>
<option value="America/Sao_Paulo">(GMT-03:00) Brasilia</option>
<option value="America/Noronha">(GMT-02:00) Mid-Atlantic</option>
<option value="Atlantic/Cape_Verde">(GMT-01:00) Cape Verde Is.</option>
<option value="Atlantic/Azores">(GMT-01:00) Azores</option>
<option value="Europe/Belfast">(GMT) Greenwich Mean Time : Belfast</option>
<option value="Europe/Dublin">(GMT) Greenwich Mean Time : Dublin</option>
<option value="Europe/Lisbon">(GMT) Greenwich Mean Time : Lisbon</option>
<option value="Europe/London">(GMT) Greenwich Mean Time : London</option>
<option value="Africa/Abidjan">(GMT) Monrovia, Reykjavik</option>
<option value="Europe/Amsterdam">(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</option>
<option value="Europe/Belgrade">(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</option>
<option value="Europe/Brussels">(GMT+01:00) Brussels, Copenhagen, Madrid, Paris</option>
<option value="Africa/Algiers">(GMT+01:00) West Central Africa</option>
<option value="Africa/Windhoek">(GMT+01:00) Windhoek</option>
<option value="Asia/Beirut">(GMT+02:00) Beirut</option>
<option value="Africa/Cairo">(GMT+02:00) Cairo</option>
<option value="Asia/Gaza">(GMT+02:00) Gaza</option>
<option value="Africa/Blantyre">(GMT+02:00) Harare, Pretoria</option>
<option value="Asia/Jerusalem">(GMT+02:00) Jerusalem</option>
<option value="Europe/Minsk">(GMT+02:00) Minsk</option>
<option value="Asia/Damascus">(GMT+02:00) Syria</option>
<option value="Europe/Moscow">(GMT+03:00) Moscow, St. Petersburg, Volgograd</option>
<option value="Africa/Addis_Ababa">(GMT+03:00) Nairobi</option>
<option value="Asia/Tehran">(GMT+03:30) Tehran</option>
<option value="Asia/Dubai">(GMT+04:00) Abu Dhabi, Muscat</option>
<option value="Asia/Yerevan">(GMT+04:00) Yerevan</option>
<option value="Asia/Kabul">(GMT+04:30) Kabul</option>
<option value="Asia/Yekaterinburg">(GMT+05:00) Ekaterinburg</option>
<option value="Asia/Tashkent">(GMT+05:00) Tashkent</option>
<option value="Asia/Kolkata">(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi</option>
<option value="Asia/Katmandu">(GMT+05:45) Kathmandu</option>
<option value="Asia/Dhaka">(GMT+06:00) Astana, Dhaka</option>
<option value="Asia/Novosibirsk">(GMT+06:00) Novosibirsk</option>
<option value="Asia/Rangoon">(GMT+06:30) Yangon (Rangoon)</option>
<option value="Asia/Bangkok">(GMT+07:00) Bangkok, Hanoi, Jakarta</option>
<option value="Asia/Krasnoyarsk">(GMT+07:00) Krasnoyarsk</option>
<option value="Asia/Hong_Kong">(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi</option>
<option value="Asia/Irkutsk">(GMT+08:00) Irkutsk, Ulaan Bataar</option>
<option value="Australia/Perth">(GMT+08:00) Perth</option>
<option value="Australia/Eucla">(GMT+08:45) Eucla</option>
<option value="Asia/Tokyo">(GMT+09:00) Osaka, Sapporo, Tokyo</option>
<option value="Asia/Seoul">(GMT+09:00) Seoul</option>
<option value="Asia/Yakutsk">(GMT+09:00) Yakutsk</option>
<option value="Australia/Adelaide">(GMT+09:30) Adelaide</option>
<option value="Australia/Darwin">(GMT+09:30) Darwin</option>
<option value="Australia/Brisbane">(GMT+10:00) Brisbane</option>
<option value="Australia/Hobart">(GMT+10:00) Hobart</option>
<option value="Asia/Vladivostok">(GMT+10:00) Vladivostok</option>
<option value="Australia/Lord_Howe">(GMT+10:30) Lord Howe Island</option>
<option value="Etc/GMT-11">(GMT+11:00) Solomon Is., New Caledonia</option>
<option value="Asia/Magadan">(GMT+11:00) Magadan</option>
<option value="Pacific/Norfolk">(GMT+11:30) Norfolk Island</option>
<option value="Asia/Anadyr">(GMT+12:00) Anadyr, Kamchatka</option>
<option value="Pacific/Auckland">(GMT+12:00) Auckland, Wellington</option>
<option value="Etc/GMT-12">(GMT+12:00) Fiji, Kamchatka, Marshall Is.</option>
<option value="Pacific/Chatham">(GMT+12:45) Chatham Islands</option>
<option value="Pacific/Tongatapu">(GMT+13:00) Nuku'alofa</option>
<option value="Pacific/Kiritimati">(GMT+14:00) Kiritimati</option>
</select>
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>until</code>
<div class="help">If given, this must be a
<code>Date</code>
instance, that will specify the limit of the recurrence. If a recurrence instance happens to be the same as the
<code>Date</code> instance given in the
<code>until</code>
argument, this will be the last occurrence.
</div>
</div>
</th>
<td>
<input type="datetime-local" name="until" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>count</code>
<div class="help">How many occurrences will be generated.
</div>
</div>
</th>
<td>
<input type="number" max="1000" min="1" value="30" name="count" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>interval</code>
<div class="help">The interval between each freq iteration. For example, when using
<code>RRule.YEARLY</code>, an interval of
<code>2</code> means once every two years, but with
<code>RRule.HOURLY</code>, it means once every two hours. The default interval is
<code>1</code>.
</div>
</div>
</th>
<td>
<input type="number" value="1" min="1" name="interval" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>wkst</code>
<div class="help"> The week start day. Must be one of the
<code>RRule.MO</code>,
<code>RRule.TU</code>,
<code>RRule.WE</code>
constants, or an integer, specifying the first day of the week. This will affect recurrences based on weekly periods. The
default week start is
<code>RRule.MO</code>.
</div>
</div>
</th>
<td>
<label>
<input type="radio" name="wkst" value="0" checked />RRule.MO</label>
<label>
<input type="radio" name="wkst" value="1" />RRule.TU</label>
<label>
<input type="radio" name="wkst" value="2" />RRule.WE</label>
<label>
<input type="radio" name="wkst" value="3" />RRule.TH</label>
<label>
<input type="radio" name="wkst" value="4" />RRule.FR</label>
<label>
<input type="radio" name="wkst" value="5" />RRule.SA</label>
<label>
<input type="radio" name="wkst" value="6" />RRule.SU</label>
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>byweekday</code>
<div class="help">If given, it must be either an integer (
<code>0 == RRule.MO</code>), a sequence of integers, one of the weekday constants (
<code>RRule.MO</code>,
<code>RRule.TU</code>, etc), or a sequence of these constants. When given, these variables will define
the weekdays where the recurrence will be applied. It's also possible to use an argument n for the
weekday instances, which will mean the nth occurrence of this weekday in the period. For example,
with
<code>RRule.MONTHLY</code>, or with
<code>RRule.YEARLY</code> and
<code>BYMONTH</code>, using
<code>RRule.FR.clone(+1)</code> in
<code>byweekday</code> will specify the first friday of the month where the recurrence happens. Notice
that the RFC documentation, this is specified as
<code>BYDAY</code>, but was renamed to avoid the ambiguity of that argument.
</div>
</div>
</th>
<td>
<label>
<input type="checkbox" name="byweekday" value="0">RRule.MO</label>
<label>
<input type="checkbox" name="byweekday" value="1">RRule.TU</label>
<label>
<input type="checkbox" name="byweekday" value="2">RRule.WE</label>
<label>
<input type="checkbox" name="byweekday" value="3">RRule.TH</label>
<label>
<input type="checkbox" name="byweekday" value="4">RRule.FR</label>
<label>
<input type="checkbox" name="byweekday" value="5">RRule.SA</label>
<label>
<input type="checkbox" name="byweekday" value="6">RRule.SU</label>
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>bymonth</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the months to apply the
recurrence to.
</div>
</div>
</th>
<td>
<label>
<input name="bymonth" type="checkbox" value="1" /> Jan</label>
<label>
<input name="bymonth" type="checkbox" value="2" /> Feb</label>
<label>
<input name="bymonth" type="checkbox" value="3" /> Mar</label>
<label>
<input name="bymonth" type="checkbox" value="4" /> Apr</label>
<label>
<input name="bymonth" type="checkbox" value="5" /> May</label>
<label>
<input name="bymonth" type="checkbox" value="6" /> Jun</label>
<label>
<input name="bymonth" type="checkbox" value="7" /> Jul</label>
<label>
<input name="bymonth" type="checkbox" value="8" /> Aug</label>
<label>
<input name="bymonth" type="checkbox" value="9" /> Sep</label>
<label>
<input name="bymonth" type="checkbox" value="10" /> Oct</label>
<label>
<input name="bymonth" type="checkbox" value="11" /> Nov</label>
<label>
<input name="bymonth" type="checkbox" value="12" /> Dec</label>
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>bysetpos</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, positive or negative. Each given
integer will specify an occurrence number, corresponding to the nth occurrence of the rule inside
the frequency period. For example, a
<code>bysetpos</code> of
<code>-1</code> if combined with a
<code>RRule.MONTHLY</code>
frequency, and a byweekday of (
<code>RRule.MO</code>,
<code>RRule.TU</code>,
<code>RRule.WE</code>,
<code>RRule.TH</code>,
<code>RRule.FR</code>), will result in the last work day of every month.
</div>
</div>
</th>
<td>
<input name="bysetpos" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>bymonthday</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the month days to apply
the recurrence to.
</div>
</div>
</th>
<td>
<input name="bymonthday" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>byyearday</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the year days to apply the
recurrence to.
</div>
</div>
</th>
<td>
<input name="byyearday" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>byweekno</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the week numbers to apply
the recurrence to. Week numbers have the meaning described in ISO8601, that is, the first week of
the year is that containing at least four days of the new year.
</div>
</div>
</th>
<td>
<input name="byweekno">
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>byhour</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the hours to apply the recurrence
to.
</div>
</div>
</th>
<td>
<input name="byhour">
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>byminute</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the minutes to apply the
recurrence to.
</div>
</div>
</th>
<td>
<input name="byminute" />
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>bysecond</code>
<div class="help">If given, it must be either an integer, or a sequence of integers, meaning the seconds to apply the
recurrence to.
</div>
</div>
</th>
<td>
<input name="bysecond">
</td>
</tr>
<tr>
<th>
<div class="option-name">
<code>byeaster</code>
<div class="help">
This is an extension to the RFC specification which the Python implementation provides.
<strong>Not implemented in the JavaScript version.
</strong>
</div>
</div>
</th>
<td>
<input disabled>
</td>
</tr>
</tbody>
</table>
</form>
</section>
<section id="rfc-input">
<h3>
<code>RRULE</code> string</h3>
<p>
<input value="FREQ=DAILY;INTERVAL=2;COUNT=4" />
</p>
<p>
Enter an
<code>RRULE</code> as per
<a href="http://www.kanzaki.com/docs/ical/rrule.html">iCalendar RFC</a>.
</p>
<p>Examples:</p>
<ul class="examples">
<li>
<code>FREQ=WEEKLY;BYDAY=MO,WE</code>
</li>
<li>
<code>FREQ=MONTHLY;BYMONTHDAY=10,15;COUNT=20</code>
</li>
<li>
<code>FREQ=DAILY;INTERVAL=3;COUNT=10</code>
</li>
<li>
<code>FREQ=MONTHLY;BYDAY=-2FR;COUNT=7</code>
</li>
</ul>
</section>
<section id="text-input">
<h3>Text input</h3>
<p>
<input value="Every 2 weeks on Friday for 6 times" />
</p>
<p>Examples:</p>
<ul class="examples">
<li>
<code>Every weekday</code>
</li>
<li>
<code>Every 2 weeks on Tuesday</code>
</li>
<li>
<code>Every week on Monday, Wednesday</code>
</li>
<li>
<code>Every month on the 2nd last Friday for 7 times</code>
</li>
<li>
<code>Every 6 months</code>
</li>
</ul>
</section>
</div>
</div>
</div>
<a href="https://github.com/jakubroztocil/rrule">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"
alt="Fork me on GitHub">
</a>
<script type="text/javascript" src="demo.js"></script></body>
</html>
+23
View File
@@ -0,0 +1,23 @@
import { IterArgs } from './iterresult';
export declare type CacheKeys = 'before' | 'after' | 'between';
export declare class Cache {
all: Date[] | Partial<IterArgs> | false;
before: IterArgs[];
after: IterArgs[];
between: IterArgs[];
/**
* @param {String} what - all/before/after/between
* @param {Array,Date} value - an array of dates, one date, or null
* @param {Object?} args - _iter arguments
*/
_cacheAdd(what: CacheKeys | 'all', value: Date[] | Date | null, args?: Partial<IterArgs>): void;
/**
* @return false - not in the cache
* null - cached, but zero occurrences (before/after)
* Date - cached (before/after)
* [] - cached, but zero occurrences (all/between)
* [Date1, DateN] - cached (all/between)
*/
_cacheGet(what: CacheKeys | 'all', args?: Partial<IterArgs>): Date | Date[] | false | null;
}
//# sourceMappingURL=cache.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/cache.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAInD,oBAAY,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAEtD,qBAAa,KAAK;IAChB,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAQ;IAC/C,MAAM,EAAE,QAAQ,EAAE,CAAK;IACvB,KAAK,EAAE,QAAQ,EAAE,CAAK;IACtB,OAAO,EAAE,QAAQ,EAAE,CAAK;IAExB;;;;OAIG;IACI,SAAS,CACd,IAAI,EAAE,SAAS,GAAG,KAAK,EACvB,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,EAC3B,IAAI,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;IAiB1B;;;;;;OAMG;IACI,SAAS,CACd,IAAI,EAAE,SAAS,GAAG,KAAK,EACvB,IAAI,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,GACvB,IAAI,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI;CA6ChC"}
+85
View File
@@ -0,0 +1,85 @@
import IterResult from './iterresult';
import dateutil from './dateutil';
import { isArray } from './helpers';
var Cache = /** @class */ (function () {
function Cache() {
this.all = false;
this.before = [];
this.after = [];
this.between = [];
}
/**
* @param {String} what - all/before/after/between
* @param {Array,Date} value - an array of dates, one date, or null
* @param {Object?} args - _iter arguments
*/
Cache.prototype._cacheAdd = function (what, value, args) {
if (value) {
value =
value instanceof Date
? dateutil.clone(value)
: dateutil.cloneDates(value);
}
if (what === 'all') {
this.all = value;
}
else {
args._value = value;
this[what].push(args);
}
};
/**
* @return false - not in the cache
* null - cached, but zero occurrences (before/after)
* Date - cached (before/after)
* [] - cached, but zero occurrences (all/between)
* [Date1, DateN] - cached (all/between)
*/
Cache.prototype._cacheGet = function (what, args) {
var cached = false;
var argsKeys = args ? Object.keys(args) : [];
var findCacheDiff = function (item) {
for (var i = 0; i < argsKeys.length; i++) {
var key = argsKeys[i];
if (String(args[key]) !== String(item[key])) {
return true;
}
}
return false;
};
var cachedObject = this[what];
if (what === 'all') {
cached = this.all;
}
else if (isArray(cachedObject)) {
// Let's see whether we've already called the
// 'what' method with the same 'args'
for (var i = 0; i < cachedObject.length; i++) {
var item = cachedObject[i];
if (argsKeys.length && findCacheDiff(item))
continue;
cached = item._value;
break;
}
}
if (!cached && this.all) {
// Not in the cache, but we already know all the occurrences,
// so we can find the correct dates from the cached ones.
var iterResult = new IterResult(what, args);
for (var i = 0; i < this.all.length; i++) {
if (!iterResult.accept(this.all[i]))
break;
}
cached = iterResult.getValue();
this._cacheAdd(what, cached, args);
}
return isArray(cached)
? dateutil.cloneDates(cached)
: cached instanceof Date
? dateutil.clone(cached)
: cached;
};
return Cache;
}());
export { Cache };
//# sourceMappingURL=cache.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,UAAwB,MAAM,cAAc,CAAA;AACnD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC;IAAA;QACE,QAAG,GAAuC,KAAK,CAAA;QAC/C,WAAM,GAAe,EAAE,CAAA;QACvB,UAAK,GAAe,EAAE,CAAA;QACtB,YAAO,GAAe,EAAE,CAAA;IAkF1B,CAAC;IAhFC;;;;OAIG;IACI,yBAAS,GAAhB,UACE,IAAuB,EACvB,KAA2B,EAC3B,IAAwB;QAExB,IAAI,KAAK,EAAE;YACT,KAAK;gBACH,KAAK,YAAY,IAAI;oBACnB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;oBACvB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;SACjC;QAED,IAAI,IAAI,KAAK,KAAK,EAAE;YAClB,IAAI,CAAC,GAAG,GAAG,KAAe,CAAA;SAC3B;aAAM;YACL,IAAK,CAAC,MAAM,GAAG,KAAK,CAAA;YACpB,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAgB,CAAC,CAAA;SAClC;IACH,CAAC;IAED;;;;;;OAMG;IACI,yBAAS,GAAhB,UACE,IAAuB,EACvB,IAAwB;QAExB,IAAI,MAAM,GAAiC,KAAK,CAAA;QAChD,IAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAwB,CAAC,CAAC,CAAC,EAAE,CAAA;QACtE,IAAM,aAAa,GAAG,UAAU,IAAc;YAC5C,KAAK,IAAI,CAAC,GA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U,CAAA;YACtC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;SACnC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC;YACpB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;YAC7B,CAAC,CAAC,MAAM,YAAY,IAAI;gBACtB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;gBACxB,CAAC,CAAC,MAAM,CAAA;IACd,CAAC;IAEH,YAAC;AAAD,CAAC,AAtFD,IAsFC"}
+13
View File
@@ -0,0 +1,13 @@
import IterResult, { IterArgs } from './iterresult';
declare type Iterator = (d: Date, len: number) => boolean;
/**
* IterResult subclass that calls a callback function on each add,
* and stops iterating when the callback returns false.
*/
export default class CallbackIterResult extends IterResult<'all' | 'between'> {
private iterator;
constructor(method: 'all' | 'between', args: Partial<IterArgs>, iterator: Iterator);
add(date: Date): boolean;
}
export {};
//# sourceMappingURL=callbackiterresult.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"callbackiterresult.d.ts","sourceRoot":"","sources":["../../../src/callbackiterresult.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEnD,aAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3E,OAAO,CAAC,QAAQ,CAAU;gBAGxB,MAAM,EAAE,KAAK,GAAG,SAAS,EACzB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,EACvB,QAAQ,EAAE,QAAQ;IAOpB,GAAG,CAAE,IAAI,EAAE,IAAI;CAOhB"}
+24
View File
@@ -0,0 +1,24 @@
import { __extends } from "tslib";
import IterResult from './iterresult';
/**
* IterResult subclass that calls a callback function on each add,
* and stops iterating when the callback returns false.
*/
var CallbackIterResult = /** @class */ (function (_super) {
__extends(CallbackIterResult, _super);
function CallbackIterResult(method, args, iterator) {
var _this = _super.call(this, method, args) || this;
_this.iterator = iterator;
return _this;
}
CallbackIterResult.prototype.add = function (date) {
if (this.iterator(date, this._result.length)) {
this._result.push(date);
return true;
}
return false;
};
return CallbackIterResult;
}(IterResult));
export default CallbackIterResult;
//# sourceMappingURL=callbackiterresult.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"callbackiterresult.js","sourceRoot":"","sources":["../../../src/callbackiterresult.ts"],"names":[],"mappings":";AAAA,OAAO,UAAwB,MAAM,cAAc,CAAA;AAInD;;;GAGG;AACH;IAAgD,sCAA6B;IAG3E,4BACE,MAAyB,EACzB,IAAuB,EACvB,QAAkB;QAHpB,YAKE,kBAAM,MAAM,EAAE,IAAI,CAAC,SAGpB;QADC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;;IAC1B,CAAC;IAED,gCAAG,GAAH,UAAK,IAAU;QACb,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACvB,OAAO,IAAI,CAAA;SACZ;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACH,yBAAC;AAAD,CAAC,AApBD,CAAgD,UAAU,GAoBzD"}
+35
View File
@@ -0,0 +1,35 @@
import { ParsedOptions } from './types';
export declare class Time {
hour: number;
minute: number;
second: number;
millisecond: number;
constructor(hour: number, minute: number, second: number, millisecond: number);
getHours(): number;
getMinutes(): number;
getSeconds(): number;
getMilliseconds(): number;
getTime(): number;
}
export declare class DateTime extends Time {
day: number;
month: number;
year: number;
static fromDate(date: Date): DateTime;
constructor(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number);
getWeekday(): number;
getTime(): number;
getDay(): number;
getMonth(): number;
getYear(): number;
addYears(years: number): void;
addMonths(months: number): void;
addWeekly(days: number, wkst: number): void;
addDaily(days: number): void;
addHours(hours: number, filtered: boolean, byhour: number[]): void;
addMinutes(minutes: number, filtered: boolean, byhour: number[], byminute: number[]): void;
addSeconds(seconds: number, filtered: boolean, byhour: number[], byminute: number[], bysecond: number[]): void;
fixDay(): void;
add(options: ParsedOptions, filtered: boolean): void;
}
//# sourceMappingURL=datetime.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../src/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,SAAS,CAAA;AAIlD,qBAAa,IAAI;IACR,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;gBAGtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM;IAQvB,QAAQ;IAIR,UAAU;IAIV,UAAU;IAIV,eAAe;IAIf,OAAO;CAMR;AAED,qBAAa,QAAS,SAAQ,IAAI;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IAEnB,MAAM,CAAC,QAAQ,CAAE,IAAI,EAAE,IAAI;gBAavB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM;IAQvB,UAAU;IAIV,OAAO;IAQP,MAAM;IAIN,QAAQ;IAIR,OAAO;IAIA,QAAQ,CAAE,KAAK,EAAE,MAAM;IAIvB,SAAS,CAAE,MAAM,EAAE,MAAM;IAczB,SAAS,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAUrC,QAAQ,CAAE,IAAI,EAAE,MAAM;IAKtB,QAAQ,CAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;IAkB5D,UAAU,CAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;IAwBpF,UAAU,CAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;IA2BxG,MAAM;IAyBN,GAAG,CAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO;CAoBtD"}
+178
View File
@@ -0,0 +1,178 @@
import { __extends } from "tslib";
import { Frequency } from './types';
import { pymod, divmod, empty, includes } from './helpers';
import { dateutil } from './dateutil';
var Time = /** @class */ (function () {
function Time(hour, minute, second, millisecond) {
this.hour = hour;
this.minute = minute;
this.second = second;
this.millisecond = millisecond || 0;
}
Time.prototype.getHours = function () {
return this.hour;
};
Time.prototype.getMinutes = function () {
return this.minute;
};
Time.prototype.getSeconds = function () {
return this.second;
};
Time.prototype.getMilliseconds = function () {
return this.millisecond;
};
Time.prototype.getTime = function () {
return ((this.hour * 60 * 60 + this.minute * 60 + this.second) * 1000 +
this.millisecond);
};
return Time;
}());
export { Time };
var DateTime = /** @class */ (function (_super) {
__extends(DateTime, _super);
function DateTime(year, month, day, hour, minute, second, millisecond) {
var _this = _super.call(this, hour, minute, second, millisecond) || this;
_this.year = year;
_this.month = month;
_this.day = day;
return _this;
}
DateTime.fromDate = function (date) {
return new this(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.valueOf() % 1000);
};
DateTime.prototype.getWeekday = function () {
return dateutil.getWeekday(new Date(this.getTime()));
};
DateTime.prototype.getTime = function () {
return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond)).getTime();
};
DateTime.prototype.getDay = function () {
return this.day;
};
DateTime.prototype.getMonth = function () {
return this.month;
};
DateTime.prototype.getYear = function () {
return this.year;
};
DateTime.prototype.addYears = function (years) {
this.year += years;
};
DateTime.prototype.addMonths = function (months) {
this.month += months;
if (this.month > 12) {
var yearDiv = Math.floor(this.month / 12);
var monthMod = pymod(this.month, 12);
this.month = monthMod;
this.year += yearDiv;
if (this.month === 0) {
this.month = 12;
--this.year;
}
}
};
DateTime.prototype.addWeekly = function (days, wkst) {
if (wkst > this.getWeekday()) {
this.day += -(this.getWeekday() + 1 + (6 - wkst)) + days * 7;
}
else {
this.day += -(this.getWeekday() - wkst) + days * 7;
}
this.fixDay();
};
DateTime.prototype.addDaily = function (days) {
this.day += days;
this.fixDay();
};
DateTime.prototype.addHours = function (hours, filtered, byhour) {
if (filtered) {
// Jump to one iteration before next day
this.hour += Math.floor((23 - this.hour) / hours) * hours;
}
while (true) {
this.hour += hours;
var _a = divmod(this.hour, 24), dayDiv = _a.div, hourMod = _a.mod;
if (dayDiv) {
this.hour = hourMod;
this.addDaily(dayDiv);
}
if (empty(byhour) || includes(byhour, this.hour))
break;
}
};
DateTime.prototype.addMinutes = function (minutes, filtered, byhour, byminute) {
if (filtered) {
// Jump to one iteration before next day
this.minute +=
Math.floor((1439 - (this.hour * 60 + this.minute)) / minutes) * minutes;
}
while (true) {
this.minute += minutes;
var _a = divmod(this.minute, 60), hourDiv = _a.div, minuteMod = _a.mod;
if (hourDiv) {
this.minute = minuteMod;
this.addHours(hourDiv, false, byhour);
}
if ((empty(byhour) || includes(byhour, this.hour)) &&
(empty(byminute) || includes(byminute, this.minute))) {
break;
}
}
};
DateTime.prototype.addSeconds = function (seconds, filtered, byhour, byminute, bysecond) {
if (filtered) {
// Jump to one iteration before next day
this.second +=
Math.floor((86399 - (this.hour * 3600 + this.minute * 60 + this.second)) / seconds) * seconds;
}
while (true) {
this.second += seconds;
var _a = divmod(this.second, 60), minuteDiv = _a.div, secondMod = _a.mod;
if (minuteDiv) {
this.second = secondMod;
this.addMinutes(minuteDiv, false, byhour, byminute);
}
if ((empty(byhour) || includes(byhour, this.hour)) &&
(empty(byminute) || includes(byminute, this.minute)) &&
(empty(bysecond) || includes(bysecond, this.second))) {
break;
}
}
};
DateTime.prototype.fixDay = function () {
if (this.day <= 28) {
return;
}
var daysinmonth = dateutil.monthRange(this.year, this.month - 1)[1];
if (this.day <= daysinmonth) {
return;
}
while (this.day > daysinmonth) {
this.day -= daysinmonth;
++this.month;
if (this.month === 13) {
this.month = 1;
++this.year;
if (this.year > dateutil.MAXYEAR) {
return;
}
}
daysinmonth = dateutil.monthRange(this.year, this.month - 1)[1];
}
};
DateTime.prototype.add = function (options, filtered) {
var freq = options.freq, interval = options.interval, wkst = options.wkst, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
switch (freq) {
case Frequency.YEARLY: return this.addYears(interval);
case Frequency.MONTHLY: return this.addMonths(interval);
case Frequency.WEEKLY: return this.addWeekly(interval, wkst);
case Frequency.DAILY: return this.addDaily(interval);
case Frequency.HOURLY: return this.addHours(interval, filtered, byhour);
case Frequency.MINUTELY: return this.addMinutes(interval, filtered, byhour, byminute);
case Frequency.SECONDLY: return this.addSeconds(interval, filtered, byhour, byminute, bysecond);
}
};
return DateTime;
}(Time));
export { DateTime };
//# sourceMappingURL=datetime.js.map
File diff suppressed because one or more lines are too long
+74
View File
@@ -0,0 +1,74 @@
import { Time } from './datetime';
/**
* General date-related utilities.
* Also handles several incompatibilities between JavaScript and Python
*
*/
export declare namespace dateutil {
const MONTH_DAYS: number[];
/**
* Number of milliseconds of one day
*/
const ONE_DAY: number;
/**
* @see: <http://docs.python.org/library/datetime.html#datetime.MAXYEAR>
*/
const MAXYEAR = 9999;
/**
* Python uses 1-Jan-1 as the base for calculating ordinals but we don't
* want to confuse the JS engine with milliseconds > Number.MAX_NUMBER,
* therefore we use 1-Jan-1970 instead
*/
const ORDINAL_BASE: Date;
/**
* Python: MO-SU: 0 - 6
* JS: SU-SAT 0 - 6
*/
const PY_WEEKDAYS: number[];
/**
* py_date.timetuple()[7]
*/
const getYearDay: (date: Date) => number;
const isLeapYear: (year: number) => boolean;
const isDate: (value: any) => value is Date;
const isValidDate: (value: any) => value is Date;
/**
* @return {Number} the date's timezone offset in ms
*/
const tzOffset: (date: Date) => number;
/**
* @see: <http://www.mcfedries.com/JavaScript/DaysBetween.asp>
*/
const daysBetween: (date1: Date, date2: Date) => number;
/**
* @see: <http://docs.python.org/library/datetime.html#datetime.date.toordinal>
*/
const toOrdinal: (date: Date) => number;
/**
* @see - <http://docs.python.org/library/datetime.html#datetime.date.fromordinal>
*/
const fromOrdinal: (ordinal: number) => Date;
const getMonthDays: (date: Date) => number;
/**
* @return {Number} python-like weekday
*/
const getWeekday: (date: Date) => number;
/**
* @see: <http://docs.python.org/library/calendar.html#calendar.monthrange>
*/
const monthRange: (year: number, month: number) => number[];
/**
* @see: <http://docs.python.org/library/datetime.html#datetime.datetime.combine>
*/
const combine: (date: Date, time: Date | Time) => Date;
const clone: (date: Date | Time) => Date;
const cloneDates: (dates: Date[] | Time[]) => Date[];
/**
* Sorts an array of Date or dateutil.Time objects
*/
const sort: <T extends Pick<Date, "getTime">>(dates: T[]) => void;
const timeToUntilString: (time: number, utc?: boolean) => string;
const untilStringToDate: (until: string) => Date;
}
export default dateutil;
//# sourceMappingURL=dateutil.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"dateutil.d.ts","sourceRoot":"","sources":["../../../src/dateutil.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAIjC;;;;GAIG;AACH,yBAAiB,QAAQ,CAAC;IACjB,MAAM,UAAU,UAAmD,CAAA;IAE1E;;OAEG;IACI,MAAM,OAAO,QAAsB,CAAA;IAE1C;;OAEG;IACI,MAAM,OAAO,OAAO,CAAA;IAE3B;;;;OAIG;IACI,MAAM,YAAY,MAAiC,CAAA;IAE1D;;;OAGG;IACI,MAAM,WAAW,UAAwB,CAAA;IAEhD;;OAEG;IACI,MAAM,UAAU,wBAatB,CAAA;IAEM,MAAM,UAAU,2BAEtB,CAAA;IAEM,MAAM,MAAM,+BAElB,CAAA;IAEM,MAAM,WAAW,+BAEvB,CAAA;IAED;;OAEG;IACI,MAAM,QAAQ,wBAEpB,CAAA;IAED;;OAEG;IACI,MAAM,WAAW,sCASvB,CAAA;IAED;;OAEG;IACI,MAAM,SAAS,wBAErB,CAAA;IAED;;OAEG;IACI,MAAM,WAAW,2BAEvB,CAAA;IAEM,MAAM,YAAY,wBAKxB,CAAA;IAED;;OAEG;IACI,MAAM,UAAU,wBAEtB,CAAA;IAED;;OAEG;IACI,MAAM,UAAU,2CAGtB,CAAA;IAED;;OAEG;IACI,MAAM,OAAO,yCAanB,CAAA;IAEM,MAAM,KAAK,6BAGjB,CAAA;IAEM,MAAM,UAAU,oCAMtB,CAAA;IAED;;OAEG;IACI,MAAM,IAAI,uDAIhB,CAAA;IAEM,MAAM,iBAAiB,yCAY7B,CAAA;IAEM,MAAM,iBAAiB,yBAgB7B,CAAA;CAEF;AAED,eAAe,QAAQ,CAAA"}
+146
View File
@@ -0,0 +1,146 @@
import { padStart } from './helpers';
/**
* General date-related utilities.
* Also handles several incompatibilities between JavaScript and Python
*
*/
export var dateutil;
(function (dateutil) {
dateutil.MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
/**
* Number of milliseconds of one day
*/
dateutil.ONE_DAY = 1000 * 60 * 60 * 24;
/**
* @see: <http://docs.python.org/library/datetime.html#datetime.MAXYEAR>
*/
dateutil.MAXYEAR = 9999;
/**
* Python uses 1-Jan-1 as the base for calculating ordinals but we don't
* want to confuse the JS engine with milliseconds > Number.MAX_NUMBER,
* therefore we use 1-Jan-1970 instead
*/
dateutil.ORDINAL_BASE = new Date(Date.UTC(1970, 0, 1));
/**
* Python: MO-SU: 0 - 6
* JS: SU-SAT 0 - 6
*/
dateutil.PY_WEEKDAYS = [6, 0, 1, 2, 3, 4, 5];
/**
* py_date.timetuple()[7]
*/
dateutil.getYearDay = function (date) {
var dateNoTime = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
return (Math.ceil((dateNoTime.valueOf() -
new Date(date.getUTCFullYear(), 0, 1).valueOf()) /
dateutil.ONE_DAY) + 1);
};
dateutil.isLeapYear = function (year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
};
dateutil.isDate = function (value) {
return value instanceof Date;
};
dateutil.isValidDate = function (value) {
return dateutil.isDate(value) && !isNaN(value.getTime());
};
/**
* @return {Number} the date's timezone offset in ms
*/
dateutil.tzOffset = function (date) {
return date.getTimezoneOffset() * 60 * 1000;
};
/**
* @see: <http://www.mcfedries.com/JavaScript/DaysBetween.asp>
*/
dateutil.daysBetween = function (date1, date2) {
// The number of milliseconds in one day
// Convert both dates to milliseconds
var date1ms = date1.getTime() - dateutil.tzOffset(date1);
var date2ms = date2.getTime() - dateutil.tzOffset(date2);
// Calculate the difference in milliseconds
var differencems = date1ms - date2ms;
// Convert back to days and return
return Math.round(differencems / dateutil.ONE_DAY);
};
/**
* @see: <http://docs.python.org/library/datetime.html#datetime.date.toordinal>
*/
dateutil.toOrdinal = function (date) {
return dateutil.daysBetween(date, dateutil.ORDINAL_BASE);
};
/**
* @see - <http://docs.python.org/library/datetime.html#datetime.date.fromordinal>
*/
dateutil.fromOrdinal = function (ordinal) {
return new Date(dateutil.ORDINAL_BASE.getTime() + ordinal * dateutil.ONE_DAY);
};
dateutil.getMonthDays = function (date) {
var month = date.getUTCMonth();
return month === 1 && dateutil.isLeapYear(date.getUTCFullYear())
? 29
: dateutil.MONTH_DAYS[month];
};
/**
* @return {Number} python-like weekday
*/
dateutil.getWeekday = function (date) {
return dateutil.PY_WEEKDAYS[date.getUTCDay()];
};
/**
* @see: <http://docs.python.org/library/calendar.html#calendar.monthrange>
*/
dateutil.monthRange = function (year, month) {
var date = new Date(Date.UTC(year, month, 1));
return [dateutil.getWeekday(date), dateutil.getMonthDays(date)];
};
/**
* @see: <http://docs.python.org/library/datetime.html#datetime.datetime.combine>
*/
dateutil.combine = function (date, time) {
time = time || date;
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds()));
};
dateutil.clone = function (date) {
var dolly = new Date(date.getTime());
return dolly;
};
dateutil.cloneDates = function (dates) {
var clones = [];
for (var i = 0; i < dates.length; i++) {
clones.push(dateutil.clone(dates[i]));
}
return clones;
};
/**
* Sorts an array of Date or dateutil.Time objects
*/
dateutil.sort = function (dates) {
dates.sort(function (a, b) {
return a.getTime() - b.getTime();
});
};
dateutil.timeToUntilString = function (time, utc) {
if (utc === void 0) { utc = true; }
var date = new Date(time);
return [
padStart(date.getUTCFullYear().toString(), 4, '0'),
padStart(date.getUTCMonth() + 1, 2, '0'),
padStart(date.getUTCDate(), 2, '0'),
'T',
padStart(date.getUTCHours(), 2, '0'),
padStart(date.getUTCMinutes(), 2, '0'),
padStart(date.getUTCSeconds(), 2, '0'),
utc ? 'Z' : ''
].join('');
};
dateutil.untilStringToDate = function (until) {
var re = /^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/;
var bits = re.exec(until);
if (!bits)
throw new Error("Invalid UNTIL value: " + until);
return new Date(Date.UTC(parseInt(bits[1], 10), parseInt(bits[2], 10) - 1, parseInt(bits[3], 10), parseInt(bits[5], 10) || 0, parseInt(bits[6], 10) || 0, parseInt(bits[7], 10) || 0));
};
})(dateutil || (dateutil = {}));
export default dateutil;
//# sourceMappingURL=dateutil.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"dateutil.js","sourceRoot":"","sources":["../../../src/dateutil.ts"],"names":[],"mappings":"AAAA,OAAO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I,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAE3B,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,0BAAwB,KAAO,CAAC,CAAA;QAE3D,OAAO,IAAI,IAAI,CACb,IAAI,CAAC,GAAG,CACN,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EACrB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EACzB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EACrB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAC1B,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAC1B,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAC3B,CACF,CAAA;IACH,CAAC,CAAA;AAEH,CAAC,EAzLgB,QAAQ,KAAR,QAAQ,QAyLxB;AAED,eAAe,QAAQ,CAAA"}
+10
View File
@@ -0,0 +1,10 @@
export declare class DateWithZone {
date: Date;
tzid?: string | null;
constructor(date: Date, tzid?: string | null);
private get isUTC();
toString(): string;
getTime(): number;
rezonedDate(): Date;
}
//# sourceMappingURL=datewithzone.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"datewithzone.d.ts","sourceRoot":"","sources":["../../../src/datewithzone.ts"],"names":[],"mappings":"AAGA,qBAAa,YAAY;IAChB,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;gBAEd,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAK7C,OAAO,KAAK,KAAK,GAEhB;IAEM,QAAQ;IASR,OAAO;IAIP,WAAW;CAmBnB"}
+45
View File
@@ -0,0 +1,45 @@
import dateutil from './dateutil';
import { DateTime } from 'luxon';
var DateWithZone = /** @class */ (function () {
function DateWithZone(date, tzid) {
this.date = date;
this.tzid = tzid;
}
Object.defineProperty(DateWithZone.prototype, "isUTC", {
get: function () {
return !this.tzid || this.tzid.toUpperCase() === 'UTC';
},
enumerable: true,
configurable: true
});
DateWithZone.prototype.toString = function () {
var datestr = dateutil.timeToUntilString(this.date.getTime(), this.isUTC);
if (!this.isUTC) {
return ";TZID=" + this.tzid + ":" + datestr;
}
return ":" + datestr;
};
DateWithZone.prototype.getTime = function () {
return this.date.getTime();
};
DateWithZone.prototype.rezonedDate = function () {
if (this.isUTC) {
return this.date;
}
try {
var datetime = DateTime
.fromJSDate(this.date);
var rezoned = datetime.setZone(this.tzid, { keepLocalTime: true });
return rezoned.toJSDate();
}
catch (e) {
if (e instanceof TypeError) {
console.error('Using TZID without Luxon available is unsupported. Returned times are in UTC, not the requested time zone');
}
return this.date;
}
};
return DateWithZone;
}());
export { DateWithZone };
//# sourceMappingURL=datewithzone.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"datewithzone.js","sourceRoot":"","sources":["../../../src/datewithzone.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC;IAIE,sBAAa,IAAU,EAAE,IAAoB;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,sBAAY,+BAAK;aAAjB;YACE,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAA;QACxD,CAAC;;;OAAA;IAEM,+BAAQ,GAAf;QACE,IAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QAC3E,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,OAAO,WAAS,IAAI,CAAC,IAAI,SAAI,OAAS,CAAA;SACvC;QAED,OAAO,MAAI,OAAS,CAAA;IACtB,CAAC;IAEM,8BAAO,GAAd;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IAC5B,CAAC;IAEM,kCAAW,GAAlB;QACE,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,IAAI,CAAA;SACjB;QAED,IAAI;YACF,IAAM,QAAQ,GAAG,QAAQ;iBACtB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAExB,IAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;YAErE,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;SAC1B;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,YAAY,SAAS,EAAE;gBAC1B,OAAO,CAAC,KAAK,CAAC,2GAA2G,CAAC,CAAA;aAC3H;YACD,OAAO,IAAI,CAAC,IAAI,CAAA;SACjB;IACH,CAAC;IACH,mBAAC;AAAD,CAAC,AA7CD,IA6CC"}
+4
View File
@@ -0,0 +1,4 @@
export declare const DateTime: {
fromJSDate(): never;
};
//# sourceMappingURL=fake-luxon.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fake-luxon.d.ts","sourceRoot":"","sources":["../../../src/fake-luxon.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;CAIpB,CAAA"}
+6
View File
@@ -0,0 +1,6 @@
export var DateTime = {
fromJSDate: function () {
throw new TypeError();
}
};
//# sourceMappingURL=fake-luxon.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fake-luxon.js","sourceRoot":"","sources":["../../../src/fake-luxon.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,QAAQ,GAAG;IACtB,UAAU;QACR,MAAM,IAAI,SAAS,EAAE,CAAA;IACvB,CAAC;CACF,CAAA"}
+53
View File
@@ -0,0 +1,53 @@
import { WeekdayStr } from './weekday';
export declare const isPresent: <T>(value?: T | null | undefined) => value is T;
export declare const isNumber: (value?: any) => value is number;
export declare const isWeekdayStr: (value?: any) => value is WeekdayStr;
export declare const isArray: (arg: any) => arg is any[];
/**
* Simplified version of python's range()
*/
export declare const range: (start: number, end?: number) => number[];
export declare const clone: <T>(array: T[]) => T[];
export declare const repeat: <T>(value: T | T[], times: number) => (T | T[])[];
export declare const toArray: <T>(item: T | T[]) => T[];
export declare function padStart(item: string | number, targetLength: number, padString?: string): string;
/**
* Python like split
*/
export declare const split: (str: string, sep: string, num: number) => string[];
/**
* closure/goog/math/math.js:modulo
* Copyright 2006 The Closure Library Authors.
* The % operator in JavaScript returns the remainder of a / b, but differs from
* some other languages in that the result will have the same sign as the
* dividend. For example, -1 % 8 == -1, whereas in some other languages
* (such as Python) the result would be 7. This function emulates the more
* correct modulo behavior, which is useful for certain applications such as
* calculating an offset index in a circular list.
*
* @param {number} a The dividend.
* @param {number} b The divisor.
* @return {number} a % b where the result is between 0 and b (either 0 <= x < b
* or b < x <= 0, depending on the sign of b).
*/
export declare const pymod: (a: number, b: number) => number;
/**
* @see: <http://docs.python.org/library/functions.html#divmod>
*/
export declare const divmod: (a: number, b: number) => {
div: number;
mod: number;
};
export declare const empty: <T>(obj: T[] | null | undefined) => boolean;
/**
* Python-like boolean
* @return {Boolean} value of an object/primitive, taking into account
* the fact that in Python an empty list's/tuple's
* boolean value is False, whereas in JS it's true
*/
export declare const notEmpty: <T>(obj: T[] | null | undefined) => obj is T[];
/**
* Return true if a value is in an array
*/
export declare const includes: <T>(arr: T[] | null | undefined, val: T) => boolean;
//# sourceMappingURL=helpers.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,UAAU,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,SAAS,iDAErB,CAAA;AAED,eAAO,MAAM,QAAQ,kCAEpB,CAAA;AAED,eAAO,MAAM,YAAY,sCAExB,CAAA;AAED,eAAO,MAAM,OAAO,4BAAgB,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,KAAK,2CAQjB,CAAA;AAED,eAAO,MAAM,KAAK,wBAEjB,CAAA;AAED,eAAO,MAAM,MAAM,mDAUlB,CAAA;AAED,eAAO,MAAM,OAAO,2BAMnB,CAAA;AAED,wBAAgB,QAAQ,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,UAa7F;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,qDAKjB,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,kCAIjB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;;;CAElB,CAAA;AAED,eAAO,MAAM,KAAK,6CAEjB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,gDAEpB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,qDAEpB,CAAA"}
+117
View File
@@ -0,0 +1,117 @@
// =============================================================================
// Helper functions
// =============================================================================
import { ALL_WEEKDAYS } from './weekday';
export var isPresent = function (value) {
return value !== null && value !== undefined;
};
export var isNumber = function (value) {
return typeof value === 'number';
};
export var isWeekdayStr = function (value) {
return ALL_WEEKDAYS.indexOf(value) >= 0;
};
export var isArray = Array.isArray;
/**
* Simplified version of python's range()
*/
export var range = function (start, end) {
if (end === void 0) { end = start; }
if (arguments.length === 1) {
end = start;
start = 0;
}
var rang = [];
for (var i = start; i < end; i++)
rang.push(i);
return rang;
};
export var clone = function (array) {
return [].concat(array);
};
export var repeat = function (value, times) {
var i = 0;
var array = [];
if (isArray(value)) {
for (; i < times; i++)
array[i] = [].concat(value);
}
else {
for (; i < times; i++)
array[i] = value;
}
return array;
};
export var toArray = function (item) {
if (isArray(item)) {
return item;
}
return [item];
};
export function padStart(item, targetLength, padString) {
if (padString === void 0) { padString = ' '; }
var str = String(item);
targetLength = targetLength >> 0;
if (str.length > targetLength) {
return String(str);
}
targetLength = targetLength - str.length;
if (targetLength > padString.length) {
padString += repeat(padString, targetLength / padString.length);
}
return padString.slice(0, targetLength) + String(str);
}
/**
* Python like split
*/
export var split = function (str, sep, num) {
var splits = str.split(sep);
return num
? splits.slice(0, num).concat([splits.slice(num).join(sep)])
: splits;
};
/**
* closure/goog/math/math.js:modulo
* Copyright 2006 The Closure Library Authors.
* The % operator in JavaScript returns the remainder of a / b, but differs from
* some other languages in that the result will have the same sign as the
* dividend. For example, -1 % 8 == -1, whereas in some other languages
* (such as Python) the result would be 7. This function emulates the more
* correct modulo behavior, which is useful for certain applications such as
* calculating an offset index in a circular list.
*
* @param {number} a The dividend.
* @param {number} b The divisor.
* @return {number} a % b where the result is between 0 and b (either 0 <= x < b
* or b < x <= 0, depending on the sign of b).
*/
export var pymod = function (a, b) {
var r = a % b;
// If r and b differ in sign, add b to wrap the result to the correct sign.
return r * b < 0 ? r + b : r;
};
/**
* @see: <http://docs.python.org/library/functions.html#divmod>
*/
export var divmod = function (a, b) {
return { div: Math.floor(a / b), mod: pymod(a, b) };
};
export var empty = function (obj) {
return !isPresent(obj) || obj.length === 0;
};
/**
* Python-like boolean
* @return {Boolean} value of an object/primitive, taking into account
* the fact that in Python an empty list's/tuple's
* boolean value is False, whereas in JS it's true
*/
export var notEmpty = function (obj) {
return !empty(obj);
};
/**
* Return true if a value is in an array
*/
export var includes = function (arr, val) {
return notEmpty(arr) && arr.indexOf(val) !== -1;
};
//# sourceMappingURL=helpers.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,mBAAmB;AACnB,gF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il/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
* Based on:
* python-dateutil - Extensions to the standard Python datetime module.
* Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
* Copyright (c) 2012 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
*/
import RRule from './rrule';
import RRuleSet from './rruleset';
export { rrulestr } from './rrulestr';
export { Frequency, ByWeekday, Options } from './types';
export { Weekday, WeekdayStr } from './weekday';
export { RRuleStrOptions } from './rrulestr';
export { RRule, RRuleSet };
export default RRule;
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EACL,KAAK,EACL,QAAQ,EACT,CAAA;AAED,eAAe,KAAK,CAAA"}
+23
View File
@@ -0,0 +1,23 @@
/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
* Based on:
* python-dateutil - Extensions to the standard Python datetime module.
* Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
* Copyright (c) 2012 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
*/
import RRule from './rrule';
import RRuleSet from './rruleset';
export { rrulestr } from './rrulestr';
export { Frequency } from './types';
export { Weekday } from './weekday';
export { RRule, RRuleSet };
export default RRule;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAsB,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,OAAO,EAAc,MAAM,WAAW,CAAA;AAG/C,OAAO,EACL,KAAK,EACL,QAAQ,EACT,CAAA;AAED,eAAe,KAAK,CAAA"}
+4
View File
@@ -0,0 +1,4 @@
import IterResult from '../iterresult';
import { ParsedOptions, QueryMethodTypes } from '../types';
export declare function iter<M extends QueryMethodTypes>(iterResult: IterResult<M>, options: ParsedOptions): import("../types").IterResultType<M>;
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/iter/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,aAAa,EAAwB,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAUhF,wBAAgB,IAAI,CAAE,CAAC,SAAS,gBAAgB,EAAG,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,wCAqGnG"}
+138
View File
@@ -0,0 +1,138 @@
import { freqIsDailyOrGreater } from '../types';
import dateutil from '../dateutil';
import Iterinfo from '../iterinfo/index';
import RRule from '../rrule';
import { buildTimeset } from '../parseoptions';
import { notEmpty, includes, isPresent } from '../helpers';
import { DateWithZone } from '../datewithzone';
import { buildPoslist } from './poslist';
import { DateTime } from '../datetime';
export function iter(iterResult, options) {
var dtstart = options.dtstart, freq = options.freq, interval = options.interval, until = options.until, bysetpos = options.bysetpos;
var count = options.count;
if (count === 0 || interval === 0) {
return emitResult(iterResult);
}
var counterDate = DateTime.fromDate(dtstart);
var ii = new Iterinfo(options);
ii.rebuild(counterDate.year, counterDate.month);
var timeset = makeTimeset(ii, counterDate, options);
while (true) {
var _a = ii.getdayset(freq)(counterDate.year, counterDate.month, counterDate.day), dayset = _a[0], start = _a[1], end = _a[2];
var filtered = removeFilteredDays(dayset, start, end, ii, options);
if (notEmpty(bysetpos)) {
var poslist = buildPoslist(bysetpos, timeset, start, end, ii, dayset);
for (var j = 0; j < poslist.length; j++) {
var res = poslist[j];
if (until && res > until) {
return emitResult(iterResult);
}
if (res >= dtstart) {
var rezonedDate = rezoneIfNeeded(res, options);
if (!iterResult.accept(rezonedDate)) {
return emitResult(iterResult);
}
if (count) {
--count;
if (!count) {
return emitResult(iterResult);
}
}
}
}
}
else {
for (var j = start; j < end; j++) {
var currentDay = dayset[j];
if (!isPresent(currentDay)) {
continue;
}
var date = dateutil.fromOrdinal(ii.yearordinal + currentDay);
for (var k = 0; k < timeset.length; k++) {
var time = timeset[k];
var res = dateutil.combine(date, time);
if (until && res > until) {
return emitResult(iterResult);
}
if (res >= dtstart) {
var rezonedDate = rezoneIfNeeded(res, options);
if (!iterResult.accept(rezonedDate)) {
return emitResult(iterResult);
}
if (count) {
--count;
if (!count) {
return emitResult(iterResult);
}
}
}
}
}
}
if (options.interval === 0) {
return emitResult(iterResult);
}
// Handle frequency and interval
counterDate.add(options, filtered);
if (counterDate.year > dateutil.MAXYEAR) {
return emitResult(iterResult);
}
if (!freqIsDailyOrGreater(freq)) {
timeset = ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, 0);
}
ii.rebuild(counterDate.year, counterDate.month);
}
}
function isFiltered(ii, currentDay, options) {
var bymonth = options.bymonth, byweekno = options.byweekno, byweekday = options.byweekday, byeaster = options.byeaster, bymonthday = options.bymonthday, bynmonthday = options.bynmonthday, byyearday = options.byyearday;
return ((notEmpty(bymonth) && !includes(bymonth, ii.mmask[currentDay])) ||
(notEmpty(byweekno) && !ii.wnomask[currentDay]) ||
(notEmpty(byweekday) && !includes(byweekday, ii.wdaymask[currentDay])) ||
(notEmpty(ii.nwdaymask) && !ii.nwdaymask[currentDay]) ||
(byeaster !== null && !includes(ii.eastermask, currentDay)) ||
((notEmpty(bymonthday) || notEmpty(bynmonthday)) &&
!includes(bymonthday, ii.mdaymask[currentDay]) &&
!includes(bynmonthday, ii.nmdaymask[currentDay])) ||
(notEmpty(byyearday) &&
((currentDay < ii.yearlen &&
!includes(byyearday, currentDay + 1) &&
!includes(byyearday, -ii.yearlen + currentDay)) ||
(currentDay >= ii.yearlen &&
!includes(byyearday, currentDay + 1 - ii.yearlen) &&
!includes(byyearday, -ii.nextyearlen + currentDay - ii.yearlen)))));
}
function rezoneIfNeeded(date, options) {
return new DateWithZone(date, options.tzid).rezonedDate();
}
function emitResult(iterResult) {
return iterResult.getValue();
}
function removeFilteredDays(dayset, start, end, ii, options) {
var filtered = false;
for (var dayCounter = start; dayCounter < end; dayCounter++) {
var currentDay = dayset[dayCounter];
filtered = isFiltered(ii, currentDay, options);
if (filtered)
dayset[currentDay] = null;
}
return filtered;
}
function makeTimeset(ii, counterDate, options) {
var freq = options.freq, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
if (freqIsDailyOrGreater(freq)) {
return buildTimeset(options);
}
if ((freq >= RRule.HOURLY &&
notEmpty(byhour) &&
!includes(byhour, counterDate.hour)) ||
(freq >= RRule.MINUTELY &&
notEmpty(byminute) &&
!includes(byminute, counterDate.minute)) ||
(freq >= RRule.SECONDLY &&
notEmpty(bysecond) &&
!includes(bysecond, counterDate.second))) {
return [];
}
return ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, counterDate.millisecond);
}
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
import Iterinfo from '../iterinfo/index';
import { Time } from '../datetime';
export declare function buildPoslist(bysetpos: number[], timeset: Time[], start: number, end: number, ii: Iterinfo, dayset: (number | null)[]): Date[];
//# sourceMappingURL=poslist.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"poslist.d.ts","sourceRoot":"","sources":["../../../../src/iter/poslist.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,wBAAgB,YAAY,CAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,UAwCrI"}
+42
View File
@@ -0,0 +1,42 @@
import dateutil from '../dateutil';
import { pymod, isPresent, includes } from '../helpers';
export function buildPoslist(bysetpos, timeset, start, end, ii, dayset) {
var poslist = [];
for (var j = 0; j < bysetpos.length; j++) {
var daypos = void 0;
var timepos = void 0;
var pos = bysetpos[j];
if (pos < 0) {
daypos = Math.floor(pos / timeset.length);
timepos = pymod(pos, timeset.length);
}
else {
daypos = Math.floor((pos - 1) / timeset.length);
timepos = pymod(pos - 1, timeset.length);
}
var tmp = [];
for (var k = start; k < end; k++) {
var val = dayset[k];
if (!isPresent(val))
continue;
tmp.push(val);
}
var i = void 0;
if (daypos < 0) {
i = tmp.slice(daypos)[0];
}
else {
i = tmp[daypos];
}
var time = timeset[timepos];
var date = dateutil.fromOrdinal(ii.yearordinal + i);
var res = dateutil.combine(date, time);
// XXX: can this ever be in the array?
// - compare the actual date instead?
if (!includes(poslist, res))
poslist.push(res);
}
dateutil.sort(poslist);
return poslist;
}
//# sourceMapp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,GAAG,CAAC,CAAA;SACd;QACD,IAAI,CAAC,SAAQ,CAAA;QACb,IAAI,MAAM,GAAG,CAAC,EAAE;YACd,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;SACzB;aAAM;YACL,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;SAChB;QAED,IAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;QAC7B,IAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,GAAG,CAAC,CAAC,CAAA;QACrD,IAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACxC,sCAAsC;QACtC,qCAAqC;QACrC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;KAC/C;IAED,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEtB,OAAO,OAAO,CAAA;AAChB,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
export declare function easter(y: number, offset?: number): number[];
//# sourceMappingURL=easter.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"easter.d.ts","sourceRoot":"","sources":["../../../../src/iterinfo/easter.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,YAmBpD"}
+21
View File
@@ -0,0 +1,21 @@
export function easter(y, offset) {
if (offset === void 0) { offset = 0; }
var a = y % 19;
var b = Math.floor(y / 100);
var c = y % 100;
var d = Math.floor(b / 4);
var e = b % 4;
var f = Math.floor((b + 8) / 25);
var g = Math.floor((b - f + 1) / 3);
var h = Math.floor(19 * a + b - d - g + 15) % 30;
var i = Math.floor(c / 4);
var k = c % 4;
var l = Math.floor(32 + 2 * e + 2 * i - h - k) % 7;
var m = Math.floor((a + 11 * h + 22 * l) / 451);
var month = Math.floor((h + l - 7 * m + 114) / 31);
var day = ((h + l - 7 * m + 114) % 31) + 1;
var date = Date.UTC(y, month - 1, day + offset);
var yearStart = Date.UTC(y, 0, 1);
return [Math.ceil((date - yearStart) / (1000 * 60 * 60 * 24))];
}
//# sourceMappingURL=easter.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"easter.js","sourceRoot":"","sources":["../../../../src/iterinfo/easter.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAE,CAAS,EAAE,MAAkB;IAAlB,uBAAA,EAAA,UAAkB;IACnD,IAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;IAChB,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IAC7B,IAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACjB,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3B,IAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAA;IAClC,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACrC,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;IAClD,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3B,IAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IACpD,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IACjD,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;IACpD,IAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;IAC5C,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAA;IACjD,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAEnC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;AAChE,CAAC"}
+36
View File
@@ -0,0 +1,36 @@
import { ParsedOptions, Frequency } from '../types';
import { YearInfo } from './yearinfo';
import { MonthInfo } from './monthinfo';
import { Time } from '../datetime';
export declare type DaySet = [(number | null)[], number, number];
export declare type GetDayset = () => DaySet;
export default class Iterinfo {
private options;
yearinfo: YearInfo;
monthinfo: MonthInfo;
eastermask: number[] | null;
constructor(options: ParsedOptions);
rebuild(year: number, month: number): void;
get lastyear(): number | null;
get lastmonth(): number | null;
get yearlen(): 366 | 365;
get yearordinal(): number;
get mrange(): number[];
get wdaymask(): number[];
get mmask(): number[];
get wnomask(): number[] | null;
get nwdaymask(): number[];
get nextyearlen(): 366 | 365;
get mdaymask(): number[];
get nmdaymask(): number[];
ydayset(): (number | number[])[];
mdayset(_: any, month: number, __: any): (number | (number | (number | null)[] | null)[])[];
wdayset(year: number, month: number, day: number): (number | (number | (number | null)[] | null)[])[];
ddayset(year: number, month: number, day: number): (number | (number | null)[])[];
htimeset(hour: number, _: number, second: number, millisecond: number): Time[];
mtimeset(hour: number, minute: number, _: number, millisecond: number): Time[];
stimeset(hour: number, minute: number, second: number, millisecond: number): Time[];
getdayset(freq: Frequency): (y: number, m: number, d: number) => DaySet;
gettimeset(freq: Frequency.HOURLY | Frequency.MINUTELY | Frequency.SECONDLY): (h: number, m: number, s: number, ms: number) => Time[];
}
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/iterinfo/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAA;AAClD,OAAO,EAAgB,SAAS,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,oBAAY,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AACxD,oBAAY,SAAS,GAAG,MAAM,MAAM,CAAA;AAMpC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAKd,OAAO,CAAC,OAAO;IAJrB,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,EAAE,SAAS,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;gBAEb,OAAO,EAAE,aAAa;IAE3C,OAAO,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAsBpC,IAAI,QAAQ,kBAEX;IAED,IAAI,SAAS,k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
import { notEmpty, repeat, range, isPresent } from '../helpers';
import { Frequency } from '../types';
import { rebuildYear } from './yearinfo';
import { rebuildMonth } from './monthinfo';
import { easter } from './easter';
import { Time } from '../datetime';
// =============================================================================
// Iterinfo
// =============================================================================
var Iterinfo = /** @class */ (function () {
function Iterinfo(options) {
this.options = options;
}
Iterinfo.prototype.rebuild = function (year, month) {
var options = this.options;
if (year !== this.lastyear) {
this.yearinfo = rebuildYear(year, options);
}
if (notEmpty(options.bynweekday) &&
(month !== this.lastmonth || year !== this.lastyear)) {
var _a = this.yearinfo, yearlen = _a.yearlen, mrange = _a.mrange, wdaymask = _a.wdaymask;
this.monthinfo = rebuildMonth(year, month, yearlen, mrange, wdaymask, options);
}
if (isPresent(options.byeaster)) {
this.eastermask = easter(year, options.byeaster);
}
};
Object.defineProperty(Iterinfo.prototype, "lastyear", {
get: function () {
return this.monthinfo ? this.monthinfo.lastyear : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "lastmonth", {
get: function () {
return this.monthinfo ? this.monthinfo.lastmonth : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "yearlen", {
get: function () {
return this.yearinfo.yearlen;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "yearordinal", {
get: function () {
return this.yearinfo.yearordinal;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "mrange", {
get: function () {
return this.yearinfo.mrange;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "wdaymask", {
get: function () {
return this.yearinfo.wdaymask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "mmask", {
get: function () {
return this.yearinfo.mmask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "wnomask", {
get: function () {
return this.yearinfo.wnomask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "nwdaymask", {
get: function () {
return this.monthinfo ? this.monthinfo.nwdaymask : [];
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "nextyearlen", {
get: function () {
return this.yearinfo.nextyearlen;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "mdaymask", {
get: function () {
return this.yearinfo.mdaymask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo.prototype, "nmdaymask", {
get: function () {
return this.yearinfo.nmdaymask;
},
enumerable: true,
configurable: true
});
Iterinfo.prototype.ydayset = function () {
return [range(this.yearlen), 0, this.yearlen];
};
Iterinfo.prototype.mdayset = function (_, month, __) {
var start = this.mrange[month - 1];
var end = this.mrange[month];
var set = repeat(null, this.yearlen);
for (var i = start; i < end; i++)
set[i] = i;
return [set, start, end];
};
Iterinfo.prototype.wdayset = function (year, month, day) {
// We need to handle cross-year weeks here.
var set = repeat(null, this.yearlen + 7);
var i = dateutil.toOrdinal(new Date(Date.UTC(year, month - 1, day))) -
this.yearordinal;
var start = i;
for (var j = 0; j < 7; j++) {
set[i] = i;
++i;
if (this.wdaymask[i] === this.options.wkst)
break;
}
return [set, start, i];
};
Iterinfo.prototype.ddayset = function (year, month, day) {
var set = repeat(null, this.yearlen);
var i = dateutil.toOrdinal(new Date(Date.UTC(year, month - 1, day))) -
this.yearordinal;
set[i] = i;
return [set, i, i + 1];
};
Iterinfo.prototype.htimeset = function (hour, _, second, millisecond) {
var _this = this;
var set = [];
this.options.byminute.forEach(function (minute) {
set = set.concat(_this.mtimeset(hour, minute, second, millisecond));
});
dateutil.sort(set);
return set;
};
Iterinfo.prototype.mtimeset = function (hour, minute, _, millisecond) {
var set = this.options.bysecond.map(function (second) {
return new Time(hour, minute, second, millisecond);
});
dateutil.sort(set);
return set;
};
Iterinfo.prototype.stimeset = function (hour, minute, second, millisecond) {
return [new Time(hour, minute, second, millisecond)];
};
Iterinfo.prototype.getdayset = function (freq) {
switch (freq) {
case Frequency.YEARLY: return this.ydayset.bind(this);
case Frequency.MONTHLY: return this.mdayset.bind(this);
case Frequency.WEEKLY: return this.wdayset.bind(this);
case Frequency.DAILY: return this.ddayset.bind(this);
default: return this.ddayset.bind(this);
}
};
Iterinfo.prototype.gettimeset = function (freq) {
switch (freq) {
case Frequency.HOURLY: return this.htimeset.bind(this);
case Frequency.MINUTELY: return this.mtimeset.bind(this);
case Frequency.SECONDLY: return this.stimeset.bind(this);
}
};
return Iterinfo;
}());
export default Iterinfo;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
import { ParsedOptions } from '../types';
export interface MonthInfo {
lastyear: number;
lastmonth: number;
nwdaymask: number[];
}
export declare function rebuildMonth(year: number, month: number, yearlen: number, mrange: number[], wdaymask: number[], options: ParsedOptions): MonthInfo;
//# sourceMappingURL=monthinfo.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"monthinfo.d.ts","sourceRoot":"","sources":["../../../../src/iterinfo/monthinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIxC,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,aAAa,aAkDvB"}
+51
View File
@@ -0,0 +1,51 @@
import RRule from '../rrule';
import { empty, repeat, pymod } from '../helpers';
export function rebuildMonth(year, month, yearlen, mrange, wdaymask, options) {
var result = {
lastyear: year,
lastmonth: month,
nwdaymask: []
};
var ranges = [];
if (options.freq === RRule.YEARLY) {
if (empty(options.bymonth)) {
ranges = [[0, yearlen]];
}
else {
for (var j = 0; j < options.bymonth.length; j++) {
month = options.bymonth[j];
ranges.push(mrange.slice(month - 1, month + 1));
}
}
}
else if (options.freq === RRule.MONTHLY) {
ranges = [mrange.slice(month - 1, month + 1)];
}
if (empty(ranges)) {
return result;
}
// Weekly frequency won't get here, so we may not
// care about cross-year weekly periods.
result.nwdaymask = repeat(0, yearlen);
for (var j = 0; j < ranges.length; j++) {
var rang = ranges[j];
var first = rang[0];
var last = rang[1] - 1;
for (var k = 0; k < options.bynweekday.length; k++) {
var i = void 0;
var _a = options.bynweekday[k], wday = _a[0], n = _a[1];
if (n < 0) {
i = last + (n + 1) * 7;
i -= pymod(wdaymask[i] - wday, 7);
}
else {
i = first + (n - 1) * 7;
i += pymod(7 - wdaymask[i] + wday, 7);
}
if (first <= i && i <= last)
result.nwdaymask[i] = 1;
}
}
return result;
}
//# sourceMappingURL=monthinfo.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"monthinfo.js","sourceRoot":"","sources":["../../../../src/iterinfo/monthinfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAQjD,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,KAAa,EACb,OAAe,EACf,MAAgB,EAChB,QAAkB,EAClB,OAAsB;IAEtB,IAAM,MAAM,GAAc;QACxB,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,EAAE;KACd,CAAA;IAED,IAAI,MAAM,GAAe,EAAE,CAAA;IAC3B,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE;QACjC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;SACxB;aAAM;YACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,E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;aAClC;iBAAM;gBACL,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;gBACvB,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAA;aACtC;YACD,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI;gBAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;SACrD;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
+15
View File
@@ -0,0 +1,15 @@
import { ParsedOptions } from '../types';
export interface YearInfo {
yearlen: 365 | 366;
nextyearlen: 365 | 366;
yearordinal: number;
yearweekday: number;
mmask: number[];
mrange: number[];
mdaymask: number[];
nmdaymask: number[];
wdaymask: number[];
wnomask: number[] | null;
}
export declare function rebuildYear(year: number, options: ParsedOptions): YearInfo;
//# sourceMappingURL=yearinfo.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"yearinfo.d.ts","sourceRoot":"","sources":["../../../../src/iterinfo/yearinfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAKxC,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,GAAG,GAAG,GAAG,CAAA;IAClB,WAAW,EAAE,GAAG,GAAG,GAAG,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CACzB;AAED,wBAAgB,WAAW,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,YA0HhE"}
+132
View File
@@ -0,0 +1,132 @@
import { __assign } from "tslib";
import dateutil from '../dateutil';
import { empty, repeat, pymod, includes } from '../helpers';
import { M365MASK, MDAY365MASK, NMDAY365MASK, WDAYMASK, M365RANGE, M366MASK, MDAY366MASK, NMDAY366MASK, M366RANGE } from '../masks';
export function rebuildYear(year, options) {
var firstyday = new Date(Date.UTC(year, 0, 1));
var yearlen = dateutil.isLeapYear(year) ? 366 : 365;
var nextyearlen = dateutil.isLeapYear(year + 1) ? 366 : 365;
var yearordinal = dateutil.toOrdinal(firstyday);
var yearweekday = dateutil.getWeekday(firstyday);
var result = __assign(__assign({ yearlen: yearlen,
nextyearlen: nextyearlen,
yearordinal: yearordinal,
yearweekday: yearweekday }, baseYearMasks(year)), { wnomask: null });
if (empty(options.byweekno)) {
return result;
}
result.wnomask = repeat(0, yearlen + 7);
var firstwkst;
var wyearlen;
var no1wkst = firstwkst = pymod(7 - yearweekday + options.wkst, 7);
if (no1wkst >= 4) {
no1wkst = 0;
// Number of days in the year, plus the days we got
// from last year.
wyearlen =
result.yearlen + pymod(yearweekday - options.wkst, 7);
}
else {
// Number of days in the year, minus the days we
// left in last year.
wyearlen = yearlen - no1wkst;
}
var div = Math.floor(wyearlen / 7);
var mod = pymod(wyearlen, 7);
var numweeks = Math.floor(div + mod / 4);
for (var j = 0; j < options.byweekno.length; j++) {
var n = options.byweekno[j];
if (n < 0) {
n += numweeks + 1;
}
if (!(n > 0 && n <= numweeks)) {
continue;
}
var i = void 0;
if (n > 1) {
i = no1wkst + (n - 1) * 7;
if (no1wkst !== firstwkst) {
i -= 7 - firstwkst;
}
}
else {
i = no1wkst;
}
for (var k = 0; k < 7; k++) {
result.wnomask[i] = 1;
i++;
if (result.wdaymask[i] === options.wkst)
break;
}
}
if (includes(options.byweekno, 1)) {
// Check week number 1 of next year as well
// orig-TODO : Check -numweeks for next year.
var i = no1wkst + numweeks * 7;
if (no1wkst !== firstwkst)
i -= 7 - firstwkst;
if (i < yearlen) {
// If week starts in next year, we
// don't care about it.
for (var j = 0; j < 7; j++) {
result.wnomask[i] = 1;
i += 1;
if (result.wdaymask[i] === options.wkst)
break;
}
}
}
if (no1wkst) {
// Check last week number of last year as
// well. If no1wkst is 0, either the year
// started on week start, or week number 1
// got days from last year, so there are no
// days from last year's last week number in
// this year.
var lnumweeks = void 0;
if (!includes(options.byweekno, -1)) {
var lyearweekday = dateutil.getWeekday(new Date(Date.UTC(year - 1, 0, 1)));
var lno1wkst = pymod(7 - lyearweekday.valueOf() + options.wkst, 7);
var lyearlen = dateutil.isLeapYear(year - 1) ? 366 : 365;
var weekst = void 0;
if (lno1wkst >= 4) {
lno1wkst = 0;
weekst = lyearlen + pymod(lyearweekday - options.wkst, 7);
}
else {
weekst = yearlen - no1wkst;
}
lnumweeks = Math.floor(52 + pymod(weekst, 7) / 4);
}
else {
lnumweeks = -1;
}
if (includes(options.byweekno, lnumweeks)) {
for (var i = 0; i < no1wkst; i++)
result.wnomask[i] = 1;
}
}
return result;
}
function baseYearMasks(year) {
var yearlen = dateutil.isLeapYear(year) ? 366 : 365;
var firstyday = new Date(Date.UTC(year, 0, 1));
var wday = dateutil.getWeekday(firstyday);
if (yearlen === 365) {
return {
mmask: M365MASK,
mdaymask: MDAY365MASK,
nmdaymask: NMDAY365MASK,
wdaymask: WDAYMASK.slice(wday),
mrange: M365RANGE
};
}
return {
mmask: M366MASK,
mdaymask: MDAY366MASK,
nmdaymask: NMDAY366MASK,
wdaymask: WDAYMASK.slice(wday),
mrange: M366RANGE
};
}
//# sourceMappingURL=yearinfo.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"yearinfo.js","sourceRoot":"","sources":["../../../../src/iterinfo/yearinfo.ts"],"names":[],"mappings":";AACA,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,Q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,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YAC9B,MAAM,EAAE,SAAS;SAClB,CAAA;KACF;IAED,OAAO;QACL,KAAK,EAAE,QAAoB;QAC3B,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,YAAY;QACvB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC9B,MAAM,EAAE,SAAS;KAClB,CAAA;AACH,CAAC"}
+43
View File
@@ -0,0 +1,43 @@
import { QueryMethodTypes, IterResultType } from './types';
export interface IterArgs {
inc: boolean;
before: Date;
after: Date;
dt: Date;
_value: Date | Date[] | null;
}
/**
* This class helps us to emulate python's generators, sorta.
*/
export default class IterResult<M extends QueryMethodTypes> {
readonly method: M;
readonly args: Partial<IterArgs>;
readonly minDate: Date | null;
readonly maxDate: Date | null;
_result: Date[];
total: number;
constructor(method: M, args: Partial<IterArgs>);
/**
* Possibly adds a date into the result.
*
* @param {Date} date - the date isn't necessarly added to the result
* list (if it is too late/too early)
* @return {Boolean} true if it makes sense to continue the iteration
* false if we're done.
*/
accept(date: Date): boolean;
/**
*
* @param {Date} date that is part of the result.
* @return {Boolean} whether we are interested in more values.
*/
add(date: Date): boolean;
/**
* 'before' and 'after' return only one date, whereas 'all'
* and 'between' an array.
* @return {Date,Array?}
*/
getValue(): IterResultType<M>;
clone(): IterResult<M>;
}
//# sourceMappingURL=iterresult.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"iterresult.d.ts","sourceRoot":"","sources":["../../../src/iterresult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM1D,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,IAAI,CAAA;IACZ,KAAK,EAAE,IAAI,CAAA;IACX,EAAE,EAAE,IAAI,CAAA;IACR,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,CAAC,SAAS,gBAAgB;IACxD,SAAgB,MAAM,EAAE,CAAC,CAAA;IACzB,SAAgB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvC,SAAgB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAO;IAC3C,SAAgB,OAAO,EAAE,IAAI,GAAG,IAAI,CAAO;IACpC,OAAO,EAAE,IAAI,EAAE,CAAK;IACpB,KAAK,SAAI;gBAEH,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;IAgB/C;;;;;;;OAOG;IACH,MAAM,CAAE,IAAI,EAAE,IAAI;IAmBlB;;;;OAIG;IACH,GAAG,CAAE,IAAI,EAAE,IAAI;IAKf;;;;OAIG;IACH,QAAQ,IAAK,cAAc,CAAC,CAAC,CAAC;IAa9B,KAAK;CAGN"}
+87
View File
@@ -0,0 +1,87 @@
/**
* This class helps us to emulate python's generators, sorta.
*/
var IterResult = /** @class */ (function () {
function IterResult(method, args) {
this.minDate = null;
this.maxDate = null;
this._result = [];
this.total = 0;
this.method = method;
this.args = args;
if (method === 'between') {
this.maxDate = args.inc
? args.before
: new Date(args.before.getTime() - 1);
this.minDate = args.inc ? args.after : new Date(args.after.getTime() + 1);
}
else if (method === 'before') {
this.maxDate = args.inc ? args.dt : new Date(args.dt.getTime() - 1);
}
else if (method === 'after') {
this.minDate = args.inc ? args.dt : new Date(args.dt.getTime() + 1);
}
}
/**
* Possibly adds a date into the result.
*
* @param {Date} date - the date isn't necessarly added to the result
* list (if it is too late/too early)
* @return {Boolean} true if it makes sense to continue the iteration
* false if we're done.
*/
IterResult.prototype.accept = function (date) {
++this.total;
var tooEarly = this.minDate && date < this.minDate;
var tooLate = this.maxDate && date > this.maxDate;
if (this.method === 'between') {
if (tooEarly)
return true;
if (tooLate)
return false;
}
else if (this.method === 'before') {
if (tooLate)
return false;
}
else if (this.method === 'after') {
if (tooEarly)
return true;
this.add(date);
return false;
}
return this.add(date);
};
/**
*
* @param {Date} date that is part of the result.
* @return {Boolean} whether we are interested in more values.
*/
IterResult.prototype.add = function (date) {
this._result.push(date);
return true;
};
/**
* 'before' and 'after' return only one date, whereas 'all'
* and 'between' an array.
* @return {Date,Array?}
*/
IterResult.prototype.getValue = function () {
var res = this._result;
switch (this.method) {
case 'all':
case 'between':
return res;
case 'before':
case 'after':
default:
return (res.length ? res[res.length - 1] : null);
}
};
IterResult.prototype.clone = function () {
return new IterResult(this.method, this.args);
};
return IterResult;
}());
export default IterResult;
//# sourceMappingURL=iterresult.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"iterresult.js","sourceRoot":"","sources":["../../../src/iterresult.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH;IAQE,oBAAa,MAAS,EAAE,IAAuB;QAL/B,YAAO,GAAgB,IAAI,CAAA;QAC3B,YAAO,GAAgB,IAAI,CAAA;QACpC,YAAO,GAAW,EAAE,CAAA;QACpB,UAAK,GAAG,CAAC,CAAA;QAGd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG;gBACrB,CAAC,CAAC,IAAI,CAAC,MAAO;gBACd,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;SAC5E;aAAM,IAAI,MAAM,KAAK,QAAQ,EAAE;YAC9B,IAAI,CAAC,OAAO,GAA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ACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,6BAAQ,GAAR;QACE,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAA;QACxB,QAAQ,IAAI,CAAC,MAAM,EAAE;YACnB,KAAK,KAAK,CAAC;YACX,KAAK,SAAS;gBACZ,OAAO,GAAwB,CAAA;YACjC,KAAK,QAAQ,CAAC;YACd,KAAK,OAAO,CAAC;YACb;gBACE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAsB,CAAA;SACxE;IACH,CAAC;IAED,0BAAK,GAAL;QACE,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IACH,iBAAC;AAAD,CAAC,AAlFD,IAkFC"}
+5
View File
@@ -0,0 +1,5 @@
import IterResult from './iterresult';
import RRule from './rrule';
import { QueryMethodTypes, IterResultType } from './types';
export declare function iterSet<M extends QueryMethodTypes>(iterResult: IterResult<M>, _rrule: RRule[], _exrule: RRule[], _rdate: Date[], _exdate: Date[], tzid: string | undefined): IterResultType<M>;
//# sourceMappingURL=iterset.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"iterset.d.ts","sourceRoot":"","sources":["../../../src/iterset.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,SAAS,CAAA;AAI3B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE1D,wBAAgB,OAAO,CAAE,CAAC,SAAS,gBAAgB,EACjD,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,EAAE,KAAK,EAAE,EAChB,MAAM,EAAE,IAAI,EAAE,EACd,OAAO,EAAE,IAAI,EAAE,EACf,IAAI,EAAE,MAAM,GAAG,SAAS,qBAgEzB"}
+63
View File
@@ -0,0 +1,63 @@
import { DateWithZone } from './datewithzone';
import { iter } from './iter/index';
import dateutil from './dateutil';
export function iterSet(iterResult, _rrule, _exrule, _rdate, _exdate, tzid) {
var _exdateHash = {};
var _accept = iterResult.accept;
function evalExdate(after, before) {
_exrule.forEach(function (rrule) {
rrule.between(after, before, true).forEach(function (date) {
_exdateHash[Number(date)] = true;
});
});
}
_exdate.forEach(function (date) {
var zonedDate = new DateWithZone(date, tzid).rezonedDate();
_exdateHash[Number(zonedDate)] = true;
});
iterResult.accept = function (date) {
var dt = Number(date);
if (isNaN(dt))
return _accept.call(this, date);
if (!_exdateHash[dt]) {
evalExdate(new Date(dt - 1), new Date(dt + 1));
if (!_exdateHash[dt]) {
_exdateHash[dt] = true;
return _accept.call(this, date);
}
}
return true;
};
if (iterResult.method === 'between') {
evalExdate(iterResult.args.after, iterResult.args.before);
iterResult.accept = function (date) {
var dt = Number(date);
if (!_exdateHash[dt]) {
_exdateHash[dt] = true;
return _accept.call(this, date);
}
return true;
};
}
for (var i = 0; i < _rdate.length; i++) {
var zonedDate = new DateWithZone(_rdate[i], tzid).rezonedDate();
if (!iterResult.accept(new Date(zonedDate.getTime())))
break;
}
_rrule.forEach(function (rrule) {
iter(iterResult, rrule.options);
});
var res = iterResult._result;
dateutil.sort(res);
switch (iterResult.method) {
case 'all':
case 'between':
return res;
case 'before':
return ((res.length && res[res.length - 1]) || null);
case 'after':
default:
return ((res.length && res[0]) || null);
}
}
//# sourceMappingURL=iterset.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"iterset.js","sourceRoot":"","sources":["../../../src/iterset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,QAAQ,MAAM,YAAY,CAAA;AAGjC,MAAM,UAA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AC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAsB,CAAA;QAC3E,KAAK,OAAO,CAAC;QACb;YACE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAsB,CAAA;KAC/D;AACH,CAAC"}
+11
View File
@@ -0,0 +1,11 @@
declare const M365MASK: (number | number[])[];
declare const M366MASK: (number | number[])[];
declare const MDAY366MASK: number[];
declare const MDAY365MASK: number[];
declare const NMDAY366MASK: number[];
declare const NMDAY365MASK: number[];
declare const M366RANGE: number[];
declare const M365RANGE: number[];
declare const WDAYMASK: number[];
export { WDAYMASK, M365MASK, M365RANGE, M366MASK, M366RANGE, MDAY365MASK, MDAY366MASK, NMDAY365MASK, NMDAY366MASK };
//# sourceMappingURL=masks.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"masks.d.ts","sourceRoot":"","sources":["../../../src/masks.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,QAAQ,uBAcb,CAAA;AAED,QAAA,MAAM,QAAQ,uBAcb,CAAA;AAOD,QAAA,MAAM,WAAW,UAchB,CAAA;AAED,QAAA,MAAM,WAAW,UAchB,CAAA;AAOD,QAAA,MAAM,YAAY,UAcjB,CAAA;AAED,QAAA,MAAM,YAAY,UAcjB,CAAA;AAED,QAAA,MAAM,SAAS,UAA+D,CAAA;AAC9E,QAAA,MAAM,SAAS,UAA+D,CAAA;AAE9E,QAAA,MAAM,QAAQ,UAIV,CAAA;AAEJ,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,CAAA"}
+30
View File
@@ -0,0 +1,30 @@
import { __spreadArrays } from "tslib";
import { range, repeat } from './helpers';
// =============================================================================
// Date masks
// =============================================================================
// Every mask is 7 days longer to handle cross-year weekly periods.
var M365MASK = __spreadArrays(repeat(1, 31), repeat(2, 28), repeat(3, 31), repeat(4, 30), repeat(5, 31), repeat(6, 30), repeat(7, 31), repeat(8, 31), repeat(9, 30), repeat(10, 31), repeat(11, 30), repeat(12, 31), repeat(1, 7));
var M366MASK = __spreadArrays(repeat(1, 31), repeat(2, 29), repeat(3, 31), repeat(4, 30), repeat(5, 31), repeat(6, 30), repeat(7, 31), repeat(8, 31), repeat(9, 30), repeat(10, 31), repeat(11, 30), repeat(12, 31), repeat(1, 7));
var M28 = range(1, 29);
var M29 = range(1, 30);
var M30 = range(1, 31);
var M31 = range(1, 32);
var MDAY366MASK = __spreadArrays(M31, M29, M31, M30, M31, M30, M31, M31, M30, M31, M30, M31, M31.slice(0, 7));
var MDAY365MASK = __spreadArrays(M31, M28, M31, M30, M31, M30, M31, M31, M30, M31, M30, M31, M31.slice(0, 7));
var NM28 = range(-28, 0);
var NM29 = range(-29, 0);
var NM30 = range(-30, 0);
var NM31 = range(-31, 0);
var NMDAY366MASK = __spreadArrays(NM31, NM29, NM31, NM30, NM31, NM30, NM31, NM31, NM30, NM31, NM30, NM31, NM31.slice(0, 7));
var NMDAY365MASK = __spreadArrays(NM31, NM28, NM31, NM30, NM31, NM30, NM31, NM31, NM30, NM31, NM30, NM31, NM31.slice(0, 7));
var M366RANGE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
var M365RANGE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
var WDAYMASK = (function () {
var wdaymask = [];
for (var i = 0; i < 55; i++)
wdaymask = wdaymask.concat(range(7));
return wdaymask;
})();
export { WDAYMASK, M365MASK, M365RANGE, M366MASK, M366RANGE, MDAY365MASK, MDAY366MASK, NMDAY365MASK, NMDAY366MASK };
//# sourceMappingURL=masks.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"masks.js","sourceRoot":"","sources":["../../../src/masks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAS,MA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AI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACpB,CAAA;AAED,IAAM,SAAS,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAC9E,IAAM,SAAS,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAE9E,IAAM,QAAQ,GAAG,CAAC;IAChB,IAAI,QAAQ,GAAa,EAAE,CAAA;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;QAAE,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACjE,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAC,EAAE,CAAA;AAEJ,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,CAAA"}
+10
View File
@@ -0,0 +1,10 @@
export interface Language {
dayNames: string[];
monthNames: string[];
tokens: {
[k: string]: RegExp;
};
}
declare const ENGLISH: Language;
export default ENGLISH;
//# sourceMappingURL=i18n.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../src/nlp/i18n.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,EAAE;QACN,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KACpB,CAAA;CACF;AAED,QAAA,MAAM,OAAO,EAAE,QAsDd,CAAA;AAED,eAAe,OAAO,CAAA"}
+60
View File
@@ -0,0 +1,60 @@
// =============================================================================
// i18n
// =============================================================================
var ENGLISH = {
dayNames: [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
],
monthNames: [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October',
'November', 'December'
],
tokens: {
'SKIP': /^[ \r\n\t]+|^\.$/,
'number': /^[1-9][0-9]*/,
'numberAsText': /^(one|two|three)/i,
'every': /^every/i,
'day(s)': /^days?/i,
'weekday(s)': /^weekdays?/i,
'week(s)': /^weeks?/i,
'hour(s)': /^hours?/i,
'minute(s)': /^minutes?/i,
'month(s)': /^months?/i,
'year(s)': /^years?/i,
'on': /^(on|in)/i,
'at': /^(at)/i,
'the': /^the/i,
'first': /^first/i,
'second': /^second/i,
'third': /^third/i,
'nth': /^([1-9][0-9]*)(\.|th|nd|rd|st)/i,
'last': /^last/i,
'for': /^for/i,
'time(s)': /^times?/i,
'until': /^(un)?til/i,
'monday': /^mo(n(day)?)?/i,
'tuesday': /^tu(e(s(day)?)?)?/i,
'wednesday': /^we(d(n(esday)?)?)?/i,
'thursday': /^th(u(r(sday)?)?)?/i,
'friday': /^fr(i(day)?)?/i,
'saturday': /^sa(t(urday)?)?/i,
'sunday': /^su(n(day)?)?/i,
'january': /^jan(uary)?/i,
'february': /^feb(ruary)?/i,
'march': /^mar(ch)?/i,
'april': /^apr(il)?/i,
'may': /^may/i,
'june': /^june?/i,
'july': /^july?/i,
'august': /^aug(ust)?/i,
'september': /^sep(t(ember)?)?/i,
'october': /^oct(ober)?/i,
'november': /^nov(ember)?/i,
'december': /^dec(ember)?/i,
'comma': /^(,\s*|(and|or)\s*)+/i
}
};
export default ENGLISH;
//# sourceMappingURL=i18n.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../../../src/nlp/i18n.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO;AACP,gFAAgF;AAUhF,IAAM,OAAO,GAAa;IACxB,QAAQ,EAAE;QACR,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW;QAC1C,UAAU,EAAE,QAAQ,EAAE,UAAU;KACjC;IACD,UAAU,EAAE;QACV,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK;QAC9C,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS;QAChD,UAAU,EAAE,UAAU;KACvB;IACD,MAAM,EAAE;QACN,MAAM,EAAE,kBAAkB;QAC1B,QAAQ,EAAE,cAAc;QACxB,cAAc,EAAE,mBAAmB;QACnC,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,SAAS;QACnB,YAAY,EAAE,aAAa;QAC3B,SAAS,EAAE,UAAU;QACrB,SAAS,EAAE,UAAU;QACrB,WAAW,EAAE,YAAY;QACzB,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,UAAU;QACrB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,iCAAiC;QACxC,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE,gBAAgB;QAC1B,SAAS,EAAE,oBAAoB;QAC/B,WAAW,EAAE,sBAAsB;QACnC,UAAU,EAAE,qBAAqB;QACjC,QAAQ,EAAE,gBAAgB;QAC1B,UAAU,EAAE,kBAAkB;QAC9B,QAAQ,EAAE,gBAAgB;QAC1B,SAAS,EAAE,cAAc;QACzB,UAAU,EAAE,eAAe;QAC3B,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,aAAa;QACvB,WAAW,EAAE,mBAAmB;QAChC,SAAS,EAAE,cAAc;QACzB,UAAU,EAAE,eAAe;QAC3B,UAAU,EAAE,eAAe;QAC3B,OAAO,EAAE,uBAAuB;KACjC;CACF,CAAA;AAED,eAAe,OAAO,CAAA"}
+101
View File
@@ -0,0 +1,101 @@
import ToText, { DateFormatter, GetText } from './totext';
import parseText from './parsetext';
import RRule from '../index';
import { Language } from './i18n';
/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
*/
/**
*
* Implementation of RRule.fromText() and RRule::toText().
*
*
* On the client side, this file needs to be included
* when those functions are used.
*
*/
/**
* Will be able to convert some of the below described rules from
* text format to a rule object.
*
*
* RULES
*
* Every ([n])
* day(s)
* | [weekday], ..., (and) [weekday]
* | weekday(s)
* | week(s)
* | month(s)
* | [month], ..., (and) [month]
* | year(s)
*
*
* Plus 0, 1, or multiple of these:
*
* on [weekday], ..., (or) [weekday] the [monthday], [monthday], ... (or) [monthday]
*
* on [weekday], ..., (and) [weekday]
*
* on the [monthday], [monthday], ... (and) [monthday] (day of the month)
*
* on the [nth-weekday], ..., (and) [nth-weekday] (of the month/year)
*
*
* Plus 0 or 1 of these:
*
* for [n] time(s)
*
* until [date]
*
* Plus (.)
*
*
* Definitely no supported for parsing:
*
* (for year):
* in week(s) [n], ..., (and) [n]
*
* on the [yearday], ..., (and) [n] day of the year
* on day [yearday], ..., (and) [n]
*
*
* NON-TERMINALS
*
* [n]: 1, 2 ..., one, two, three ..
* [month]: January, February, March, April, May, ... December
* [weekday]: Monday, ... Sunday
* [nth-weekday]: first [weekday], 2nd [weekday], ... last [weekday], ...
* [monthday]: first, 1., 2., 1st, 2nd, second, ... 31st, last day, 2nd last day, ..
* [date]:
* [month] (0-31(,) ([year])),
* (the) 0-31.(1-12.([year])),
* (the) 0-31/(1-12/([year])),
* [weekday]
*
* [year]: 0000, 0001, ... 01, 02, ..
*
* Definitely not supported for parsing:
*
* [yearday]: first, 1., 2., 1st, 2nd, second, ... 366th, last day, 2nd last day, ..
*
* @param {String} text
* @return {Object, Boolean} the rule, or null.
*/
declare const fromText: (text: string, language?: Language) => RRule;
declare const toText: (rrule: RRule, gettext?: GetText | undefined, language?: Language | undefined, dateFormatter?: DateFormatter | undefined) => string;
declare const isFullyConvertible: typeof ToText.isFullyConvertible;
export interface Nlp {
fromText: typeof fromText;
parseText: typeof parseText;
isFullyConvertible: typeof isFullyConvertible;
toText: typeof toText;
}
export { fromText, parseText, isFullyConvertible, toText };
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/nlp/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,UAAU,CAAA;AAE5B,OAAgB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAE1C;;;;;;;;EAQE;AAEF;;;;;;;;GAQG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,QAAA,MAAM,QAAQ,8CAEb,CAAA;AAuBD,QAAA,MAAM,MAAM,qIAEX,CAAA;AAED,QAAA,MAAQ,kBAAkB,kCAAW,CAAA;AAErC,MAAM,WAAW,GAAG;IAClB,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,SAAS,EAAE,OAAO,SAAS,CAAA;IAC3B,kBAAkB,EAAE,OAAO,kBAAkB,CAAA;IAC7C,MAAM,EAAE,OAAO,MAAM,CAAA;CACtB;AAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAA"}
+122
View File
@@ -0,0 +1,122 @@
import ToText from './totext';
import parseText from './parsetext';
import RRule from '../index';
import { Frequency } from '../types';
import ENGLISH from './i18n';
/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
*/
/**
*
* Implementation of RRule.fromText() and RRule::toText().
*
*
* On the client side, this file needs to be included
* when those functions are used.
*
*/
// =============================================================================
// fromText
// =============================================================================
/**
* Will be able to convert some of the below described rules from
* text format to a rule object.
*
*
* RULES
*
* Every ([n])
* day(s)
* | [weekday], ..., (and) [weekday]
* | weekday(s)
* | week(s)
* | month(s)
* | [month], ..., (and) [month]
* | year(s)
*
*
* Plus 0, 1, or multiple of these:
*
* on [weekday], ..., (or) [weekday] the [monthday], [monthday], ... (or) [monthday]
*
* on [weekday], ..., (and) [weekday]
*
* on the [monthday], [monthday], ... (and) [monthday] (day of the month)
*
* on the [nth-weekday], ..., (and) [nth-weekday] (of the month/year)
*
*
* Plus 0 or 1 of these:
*
* for [n] time(s)
*
* until [date]
*
* Plus (.)
*
*
* Definitely no supported for parsing:
*
* (for year):
* in week(s) [n], ..., (and) [n]
*
* on the [yearday], ..., (and) [n] day of the year
* on day [yearday], ..., (and) [n]
*
*
* NON-TERMINALS
*
* [n]: 1, 2 ..., one, two, three ..
* [month]: January, February, March, April, May, ... December
* [weekday]: Monday, ... Sunday
* [nth-weekday]: first [weekday], 2nd [weekday], ... last [weekday], ...
* [monthday]: first, 1., 2., 1st, 2nd, second, ... 31st, last day, 2nd last day, ..
* [date]:
* [month] (0-31(,) ([year])),
* (the) 0-31.(1-12.([year])),
* (the) 0-31/(1-12/([year])),
* [weekday]
*
* [year]: 0000, 0001, ... 01, 02, ..
*
* Definitely not supported for parsing:
*
* [yearday]: first, 1., 2., 1st, 2nd, second, ... 366th, last day, 2nd last day, ..
*
* @param {String} text
* @return {Object, Boolean} the rule, or null.
*/
var fromText = function (text, language) {
if (language === void 0) { language = ENGLISH; }
return new RRule(parseText(text, language) || undefined);
};
var common = [
'count',
'until',
'interval',
'byweekday',
'bymonthday',
'bymonth'
];
ToText.IMPLEMENTED = [];
ToText.IMPLEMENTED[Frequency.HOURLY] = common;
ToText.IMPLEMENTED[Frequency.MINUTELY] = common;
ToText.IMPLEMENTED[Frequency.DAILY] = ['byhour'].concat(common);
ToText.IMPLEMENTED[Frequency.WEEKLY] = common;
ToText.IMPLEMENTED[Frequency.MONTHLY] = common;
ToText.IMPLEMENTED[Frequency.YEARLY] = ['byweekno', 'byyearday'].concat(common);
// =============================================================================
// Export
// =============================================================================
var toText = function (rrule, gettext, language, dateFormatter) {
return new ToText(rrule, gettext, language, dateFormatter).toString();
};
var isFullyConvertible = ToText.isFullyConvertible;
export { fromText, parseText, isFullyConvertible, toText };
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nlp/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAkC,MAAM,UAAU,CAAA;AACzD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,OAAqB,MAAM,QAAQ,CAAA;AAE1C;;;;;;;;EAQE;AAEF;;;;;;;;GAQG;AAEH,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAChF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,MAAM,EAAE,CAAA"}
+4
View File
@@ -0,0 +1,4 @@
import { Language } from './i18n';
import { Options } from '../types';
export default function parseText(text: string, language?: Language): Partial<Options> | null;
//# sourceMappingURL=parsetext.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"parsetext.d.ts","sourceRoot":"","sources":["../../../../src/nlp/parsetext.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAkGlC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAkB,2BAuV5E"}
+406
View File
@@ -0,0 +1,406 @@
import ENGLISH from './i18n';
import RRule from '../index';
// =============================================================================
// Parser
// =============================================================================
var Parser = /** @class */ (function () {
function Parser(rules) {
this.done = true;
this.rules = rules;
}
Parser.prototype.start = function (text) {
this.text = text;
this.done = false;
return this.nextSymbol();
};
Parser.prototype.isDone = function () {
return this.done && this.symbol === null;
};
Parser.prototype.nextSymbol = function () {
var best;
var bestSymbol;
var p = this;
this.symbol = null;
this.value = null;
do {
if (this.done)
return false;
var rule = void 0;
best = null;
for (var name_1 in this.rules) {
rule = this.rules[name_1];
var match = rule.exec(p.text);
if (match) {
if (best === null || match[0].length > best[0].length) {
best = match;
bestSymbol = name_1;
}
}
}
if (best != null) {
this.text = this.text.substr(best[0].length);
if (this.text === '')
this.done = true;
}
if (best == null) {
this.done = true;
this.symbol = null;
this.value = null;
return;
}
// @ts-ignore
} while (bestSymbol === 'SKIP');
// @ts-ignore
this.symbol = bestSymbol;
this.value = best;
return true;
};
Parser.prototype.accept = function (name) {
if (this.symbol === name) {
if (this.value) {
var v = this.value;
this.nextSymbol();
return v;
}
this.nextSymbol();
return true;
}
return false;
};
Parser.prototype.acceptNumber = function () {
return this.accept('number');
};
Parser.prototype.expect = function (name) {
if (this.accept(name))
return true;
throw new Error('expected ' + name + ' but found ' + this.symbol);
};
return Parser;
}());
export default function parseText(text, language) {
if (language === void 0) { language = ENGLISH; }
var options = {};
var ttr = new Parser(language.tokens);
if (!ttr.start(text))
return null;
S();
return options;
function S() {
// every [n]
ttr.expect('every');
var n = ttr.acceptNumber();
if (n)
options.interval = parseInt(n[0], 10);
if (ttr.isDone())
throw new Error('Unexpected end');
switch (ttr.symbol) {
case 'day(s)':
options.freq = RRule.DAILY;
if (ttr.nextSymbol()) {
AT();
F();
}
break;
// FIXME Note: every 2 weekdays != every two weeks on weekdays.
// DAILY on weekdays is not a valid rule
case 'weekday(s)':
options.freq = RRule.WEEKLY;
options.byweekday = [
RRule.MO,
RRule.TU,
RRule.WE,
RRule.TH,
RRule.FR
];
ttr.nextSymbol();
F();
break;
case 'week(s)':
options.freq = RRule.WEEKLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case 'hour(s)':
options.freq = RRule.HOURLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case 'minute(s)':
options.freq = RRule.MINUTELY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case 'month(s)':
options.freq = RRule.MONTHLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case 'year(s)':
options.freq = RRule.YEARLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case 'monday':
case 'tuesday':
case 'wednesday':
case 'thursday':
case 'friday':
case 'saturday':
case 'sunday':
options.freq = RRule.WEEKLY;
var key = ttr.symbol.substr(0, 2).toUpperCase();
options.byweekday = [RRule[key]];
if (!ttr.nextSymbol())
return;
// TODO check for duplicates
while (ttr.accept('comma')) {
if (ttr.isDone())
throw new Error('Unexpected end');
var wkd = decodeWKD();
if (!wkd) {
throw new Error('Unexpected symbol ' + ttr.symbol + ', expected weekday');
}
// @ts-ignore
options.byweekday.push(RRule[wkd]);
ttr.nextSymbol();
}
MDAYs();
F();
break;
case 'january':
case 'february':
case 'march':
case 'april':
case 'may':
case 'june':
case 'july':
case 'august':
case 'september':
case 'october':
case 'november':
case 'december':
options.freq = RRule.YEARLY;
options.bymonth = [decodeM()];
if (!ttr.nextSymbol())
return;
// TODO check for duplicates
while (ttr.accept('comma')) {
if (ttr.isDone())
throw new Error('Unexpected end');
var m = decodeM();
if (!m) {
throw new Error('Unexpected symbol ' + ttr.symbol + ', expected month');
}
options.bymonth.push(m);
ttr.nextSymbol();
}
ON();
F();
break;
default:
throw new Error('Unknown symbol');
}
}
function ON() {
var on = ttr.accept('on');
var the = ttr.accept('the');
if (!(on || the))
return;
do {
var nth = decodeNTH();
var wkd = decodeWKD();
var m = decodeM();
// nth <weekday> | <weekday>
if (nth) {
// ttr.nextSymbol()
if (wkd) {
ttr.nextSymbol();
if (!options.byweekday)
options.byweekday = [];
// @ts-ignore
options.byweekday.push(RRule[wkd].nth(nth));
}
else {
if (!options.bymonthday)
options.bymonthday = [];
// @ts-ignore
options.bymonthday.push(nth);
ttr.accept('day(s)');
}
// <weekday>
}
else if (wkd) {
ttr.nextSymbol();
if (!options.byweekday)
options.byweekday = [];
// @ts-ignore
options.byweekday.push(RRule[wkd]);
}
else if (ttr.symbol === 'weekday(s)') {
ttr.nextSymbol();
if (!options.byweekday) {
options.byweekday = [
RRule.MO,
RRule.TU,
RRule.WE,
RRule.TH,
RRule.FR
];
}
}
else if (ttr.symbol === 'week(s)') {
ttr.nextSymbol();
var n = ttr.acceptNumber();
if (!n) {
throw new Error('Unexpected symbol ' + ttr.symbol + ', expected week number');
}
options.byweekno = [parseInt(n[0], 10)];
while (ttr.accept('comma')) {
n = ttr.acceptNumber();
if (!n) {
throw new Error('Unexpected symbol ' + ttr.symbol + '; expected monthday');
}
options.byweekno.push(parseInt(n[0], 10));
}
}
else if (m) {
ttr.nextSymbol();
if (!options.bymonth)
options.bymonth = [];
// @ts-ignore
options.bymonth.push(m);
}
else {
return;
}
} while (ttr.accept('comma') || ttr.accept('the') || ttr.accept('on'));
}
function AT() {
var at = ttr.accept('at');
if (!at)
return;
do {
var n = ttr.acceptNumber();
if (!n) {
throw new Error('Unexpected symbol ' + ttr.symbol + ', expected hour');
}
options.byhour = [parseInt(n[0], 10)];
while (ttr.accept('comma')) {
n = ttr.acceptNumber();
if (!n) {
throw new Error('Unexpected symbol ' + ttr.symbol + '; expected hour');
}
options.byhour.push(parseInt(n[0], 10));
}
} while (ttr.accept('comma') || ttr.accept('at'));
}
function decodeM() {
switch (ttr.symbol) {
case 'january':
return 1;
case 'february':
return 2;
case 'march':
return 3;
case 'april':
return 4;
case 'may':
return 5;
case 'june':
return 6;
case 'july':
return 7;
case 'august':
return 8;
case 'september':
return 9;
case 'october':
return 10;
case 'november':
return 11;
case 'december':
return 12;
default:
return false;
}
}
function decodeWKD() {
switch (ttr.symbol) {
case 'monday':
case 'tuesday':
case 'wednesday':
case 'thursday':
case 'friday':
case 'saturday':
case 'sunday':
return ttr.symbol.substr(0, 2).toUpperCase();
default:
return false;
}
}
function decodeNTH() {
switch (ttr.symbol) {
case 'last':
ttr.nextSymbol();
return -1;
case 'first':
ttr.nextSymbol();
return 1;
case 'second':
ttr.nextSymbol();
return ttr.accept('last') ? -2 : 2;
case 'third':
ttr.nextSymbol();
return ttr.accept('last') ? -3 : 3;
case 'nth':
var v = parseInt(ttr.value[1], 10);
if (v < -366 || v > 366)
throw new Error('Nth out of range: ' + v);
ttr.nextSymbol();
return ttr.accept('last') ? -v : v;
default:
return false;
}
}
function MDAYs() {
ttr.accept('on');
ttr.accept('the');
var nth = decodeNTH();
if (!nth)
return;
options.bymonthday = [nth];
ttr.nextSymbol();
while (ttr.accept('comma')) {
nth = decodeNTH();
if (!nth) {
throw new Error('Unexpected symbol ' + ttr.symbol + '; expected monthday');
}
options.bymonthday.push(nth);
ttr.nextSymbol();
}
}
function F() {
if (ttr.symbol === 'until') {
var date = Date.parse(ttr.text);
if (!date)
throw new Error('Cannot parse until date:' + ttr.text);
options.until = new Date(date);
}
else if (ttr.accept('for')) {
options.count = parseInt(ttr.value[0], 10);
ttr.expect('number');
// ttr.expect('times')
}
}
}
//# sourceMappingURL=parsetext.js.map
File diff suppressed because one or more lines are too long
+58
View File
@@ -0,0 +1,58 @@
import { Language } from './i18n';
import RRule from '../index';
import { ByWeekday } from '../types';
import { Weekday } from '../weekday';
export declare type GetText = (id: string | number | Weekday) => string;
export declare type DateFormatter = (year: number, month: string, day: number) => string;
/**
*
* @param {RRule} rrule
* Optional:
* @param {Function} gettext function
* @param {Object} language definition
* @constructor
*/
export default class ToText {
static IMPLEMENTED: string[][];
private rrule;
private text;
private gettext;
private dateFormatter;
private language;
private options;
private origOptions;
private bymonthday;
private byweekday;
constructor(rrule: RRule, gettext?: GetText, language?: Language, dateFormatter?: DateFormatter);
/**
* Test whether the rrule can be fully converted to text.
* @param {RRule} rrule
* @return {Boolean}
*/
static isFullyConvertible(rrule: RRule): boolean;
isFullyConvertible(): boolean;
/**
* Perform the conversion. Only some of the frequencies are supported.
* If some of the rrule's options aren't supported, they'll
* be omitted from the output an "(~ approximate)" will be appended.
* @return {*}
*/
toString(): string;
HOURLY(): void;
MINUTELY(): void;
DAILY(): void;
WEEKLY(): void;
MONTHLY(): void;
YEARLY(): void;
private _bymonthday;
private _byweekday;
private _byhour;
private _bymonth;
nth(n: number | string): string;
monthtext(m: number): string;
weekdaytext(wday: Weekday | number): string;
plural(n: number): boolean;
add(s: string): this;
list(arr: ByWeekday | ByWeekday[], callback?: GetText, finalDelim?: string, delim?: string): string;
}
//# sourceMappingURL=totext.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"totext.d.ts","sourceRoot":"","sources":["../../../../src/nlp/totext.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAW,SAAS,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAkBpC,oBAAY,OAAO,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG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AO,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY;CAwCjG"}
+387
View File
@@ -0,0 +1,387 @@
import ENGLISH from './i18n';
import RRule from '../index';
import { isArray, isNumber, isPresent } from '../helpers';
// =============================================================================
// Helper functions
// =============================================================================
/**
* Return true if a value is in an array
*/
var contains = function (arr, val) {
return arr.indexOf(val) !== -1;
};
var defaultGetText = function (id) { return id.toString(); };
var defaultDateFormatter = function (year, month, day) { return month + " " + day + ", " + year; };
/**
*
* @param {RRule} rrule
* Optional:
* @param {Function} gettext function
* @param {Object} language definition
* @constructor
*/
var ToText = /** @class */ (function () {
function ToText(rrule, gettext, language, dateFormatter) {
if (gettext === void 0) { gettext = defaultGetText; }
if (language === void 0) { language = ENGLISH; }
if (dateFormatter === void 0) { dateFormatter = defaultDateFormatter; }
this.text = [];
this.language = language || ENGLISH;
this.gettext = gettext;
this.dateFormatter = dateFormatter;
this.rrule = rrule;
this.options = rrule.options;
this.origOptions = rrule.origOptions;
if (this.origOptions.bymonthday) {
var bymonthday = [].concat(this.options.bymonthday);
var bynmonthday = [].concat(this.options.bynmonthday);
bymonthday.sort(function (a, b) { return a - b; });
bynmonthday.sort(function (a, b) { return b - a; });
// 1, 2, 3, .., -5, -4, -3, ..
this.bymonthday = bymonthday.concat(bynmonthday);
if (!this.bymonthday.length)
this.bymonthday = null;
}
if (isPresent(this.origOptions.byweekday)) {
var byweekday = !isArray(this.origOptions.byweekday)
? [this.origOptions.byweekday]
: this.origOptions.byweekday;
var days = String(byweekday);
this.byweekday = {
allWeeks: byweekday.filter(function (weekday) {
return !weekday.n;
}),
someWeeks: byweekday.filter(function (weekday) {
return Boolean(weekday.n);
}),
isWeekdays: days.indexOf('MO') !== -1 &&
days.indexOf('TU') !== -1 &&
days.indexOf('WE') !== -1 &&
days.indexOf('TH') !== -1 &&
days.indexOf('FR') !== -1 &&
days.indexOf('SA') === -1 &&
days.indexOf('SU') === -1,
isEveryDay: days.indexOf('MO') !== -1 &&
days.indexOf('TU') !== -1 &&
days.indexOf('WE') !== -1 &&
days.indexOf('TH') !== -1 &&
days.indexOf('FR') !== -1 &&
days.indexOf('SA') !== -1 &&
days.indexOf('SU') !== -1
};
var sortWeekDays = function (a, b) {
return a.weekday - b.weekday;
};
this.byweekday.allWeeks.sort(sortWeekDays);
this.byweekday.someWeeks.sort(sortWeekDays);
if (!this.byweekday.allWeeks.length)
this.byweekday.allWeeks = null;
if (!this.byweekday.someWeeks.length)
this.byweekday.someWeeks = null;
}
else {
this.byweekday = null;
}
}
/**
* Test whether the rrule can be fully converted to text.
* @param {RRule} rrule
* @return {Boolean}
*/
ToText.isFullyConvertible = function (rrule) {
var canConvert = true;
if (!(rrule.options.freq in ToText.IMPLEMENTED))
return false;
if (rrule.origOptions.until && rrule.origOptions.count)
return false;
for (var key in rrule.origOptions) {
if (contains(['dtstart', 'wkst', 'freq'], key))
return true;
if (!contains(ToText.IMPLEMENTED[rrule.options.freq], key))
return false;
}
return canConvert;
};
ToText.prototype.isFullyConvertible = function () {
return ToText.isFullyConvertible(this.rrule);
};
/**
* Perform the conversion. Only some of the frequencies are supported.
* If some of the rrule's options aren't supported, they'll
* be omitted from the output an "(~ approximate)" will be appended.
* @return {*}
*/
ToText.prototype.toString = function () {
var gettext = this.gettext;
if (!(this.options.freq in ToText.IMPLEMENTED)) {
return gettext('RRule error: Unable to fully convert this rrule to text');
}
this.text = [gettext('every')];
// @ts-ignore
this[RRule.FREQUENCIES[this.options.freq]]();
if (this.options.until) {
this.add(gettext('until'));
var until = this.options.until;
this.add(this.dateFormatter(until.getUTCFullYear(), this.language.monthNames[until.getUTCMonth()], until.getUTCDate()));
}
else if (this.options.count) {
this.add(gettext('for'))
.add(this.options.count.toString())
.add(this.plural(this.options.count) ? gettext('times') : gettext('time'));
}
if (!this.isFullyConvertible())
this.add(gettext('(~ approximate)'));
return this.text.join('');
};
ToText.prototype.HOURLY = function () {
var gettext = this.gettext;
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval) ? gettext('hours') : gettext('hour'));
};
ToText.prototype.MINUTELY = function () {
var gettext = this.gettext;
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval)
? gettext('minutes')
: gettext('minute'));
};
ToText.prototype.DAILY = function () {
var gettext = this.gettext;
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
if (this.byweekday && this.byweekday.isWeekdays) {
this.add(this.plural(this.options.interval)
? gettext('weekdays')
: gettext('weekday'));
}
else {
this.add(this.plural(this.options.interval) ? gettext('days') : gettext('day'));
}
if (this.origOptions.bymonth) {
this.add(gettext('in'));
this._bymonth();
}
if (this.bymonthday) {
this._bymonthday();
}
else if (this.byweekday) {
this._byweekday();
}
else if (this.origOptions.byhour) {
this._byhour();
}
};
ToText.prototype.WEEKLY = function () {
var gettext = this.gettext;
if (this.options.interval !== 1) {
this.add(this.options.interval.toString()).add(this.plural(this.options.interval) ? gettext('weeks') : gettext('week'));
}
if (this.byweekday && this.byweekday.isWeekdays) {
if (this.options.interval === 1) {
this.add(this.plural(this.options.interval)
? gettext('weekdays')
: gettext('weekday'));
}
else {
this.add(gettext('on')).add(gettext('weekdays'));
}
}
else if (this.byweekday && this.byweekday.isEveryDay) {
this.add(this.plural(this.options.interval) ? gettext('days') : gettext('day'));
}
else {
if (this.options.interval === 1)
this.add(gettext('week'));
if (this.origOptions.bymonth) {
this.add(gettext('in'));
this._bymonth();
}
if (this.bymonthday) {
this._bymonthday();
}
else if (this.byweekday) {
this._byweekday();
}
}
};
ToText.prototype.MONTHLY = function () {
var gettext = this.gettext;
if (this.origOptions.bymonth) {
if (this.options.interval !== 1) {
this.add(this.options.interval.toString()).add(gettext('months'));
if (this.plural(this.options.interval))
this.add(gettext('in'));
}
else {
// this.add(gettext('MONTH'))
}
this._bymonth();
}
else {
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval)
? gettext('months')
: gettext('month'));
}
if (this.bymonthday) {
this._bymonthday();
}
else if (this.byweekday && this.byweekday.isWeekdays) {
this.add(gettext('on')).add(gettext('weekdays'));
}
else if (this.byweekday) {
this._byweekday();
}
};
ToText.prototype.YEARLY = function () {
var gettext = this.gettext;
if (this.origOptions.bymonth) {
if (this.options.interval !== 1) {
this.add(this.options.interval.toString());
this.add(gettext('years'));
}
else {
// this.add(gettext('YEAR'))
}
this._bymonth();
}
else {
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval) ? gettext('years') : gettext('year'));
}
if (this.bymonthday) {
this._bymonthday();
}
else if (this.byweekday) {
this._byweekday();
}
if (this.options.byyearday) {
this.add(gettext('on the'))
.add(this.list(this.options.byyearday, this.nth, gettext('and')))
.add(gettext('day'));
}
if (this.options.byweekno) {
this.add(gettext('in'))
.add(this.plural(this.options.byweekno.length)
? gettext('weeks')
: gettext('week'))
.add(this.list(this.options.byweekno, undefined, gettext('and')));
}
};
ToText.prototype._bymonthday = function () {
var gettext = this.gettext;
if (this.byweekday && this.byweekday.allWeeks) {
this.add(gettext('on'))
.add(this.list(this.byweekday.allWeeks, this.weekdaytext, gettext('or')))
.add(gettext('the'))
.add(this.list(this.bymonthday, this.nth, gettext('or')));
}
else {
this.add(gettext('on the')).add(this.list(this.bymonthday, this.nth, gettext('and')));
}
// this.add(gettext('DAY'))
};
ToText.prototype._byweekday = function () {
var gettext = this.gettext;
if (this.byweekday.allWeeks && !this.byweekday.isWeekdays) {
this.add(gettext('on')).add(this.list(this.byweekday.allWeeks, this.weekdaytext));
}
if (this.byweekday.someWeeks) {
if (this.byweekday.allWeeks)
this.add(gettext('and'));
this.add(gettext('on the')).add(this.list(this.byweekday.someWeeks, this.weekdaytext, gettext('and')));
}
};
ToText.prototype._byhour = function () {
var gettext = this.gettext;
this.add(gettext('at')).add(this.list(this.origOptions.byhour, undefined, gettext('and')));
};
ToText.prototype._bymonth = function () {
this.add(this.list(this.options.bymonth, this.monthtext, this.gettext('and')));
};
ToText.prototype.nth = function (n) {
n = parseInt(n.toString(), 10);
var nth;
var npos;
var gettext = this.gettext;
if (n === -1)
return gettext('last');
npos = Math.abs(n);
switch (npos) {
case 1:
case 21:
case 31:
nth = npos + gettext('st');
break;
case 2:
case 22:
nth = npos + gettext('nd');
break;
case 3:
case 23:
nth = npos + gettext('rd');
break;
default:
nth = npos + gettext('th');
}
return n < 0 ? nth + ' ' + gettext('last') : nth;
};
ToText.prototype.monthtext = function (m) {
return this.language.monthNames[m - 1];
};
ToText.prototype.weekdaytext = function (wday) {
var weekday = isNumber(wday) ? (wday + 1) % 7 : wday.getJsWeekday();
return ((wday.n ? this.nth(wday.n) + ' ' : '') + this.language.dayNames[weekday]);
};
ToText.prototype.plural = function (n) {
return n % 100 !== 1;
};
ToText.prototype.add = function (s) {
this.text.push(' ');
this.text.push(s);
return this;
};
ToText.prototype.list = function (arr, callback, finalDelim, delim) {
if (delim === void 0) { delim = ','; }
if (!isArray(arr)) {
arr = [arr];
}
var delimJoin = function (array, delimiter, finalDelimiter) {
var list = '';
for (var i = 0; i < array.length; i++) {
if (i !== 0) {
if (i === array.length - 1) {
list += ' ' + finalDelimiter + ' ';
}
else {
list += delimiter + ' ';
}
}
list += array[i];
}
return list;
};
callback =
callback ||
function (o) {
return o.toString();
};
var self = this;
var realCallback = function (arg) {
return callback && callback.call(self, arg);
};
if (finalDelim) {
return delimJoin(arr.map(realCallback), delim, finalDelim);
}
else {
return arr.map(realCallback).join(delim + ' ');
}
};
return ToText;
}());
export default ToText;
//# sourceMappingURL=totext.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
import { Options } from './types';
export declare function optionsToString(options: Partial<Options>): string;
//# sourceMappingURL=optionstostring.d.ts.map

Some files were not shown because too many files have changed in this diff Show More