@rschedule/moment-tz-date-adapter
Advanced tools
Changelog
0.12.1 FIX (2019/9/26)
UMD
targets es5
and es2015
targets es2015
(#34)Changelog
0.12.0 BREAKING (2019/9/15)
This is a large breaking change to the library that simplifies the API and increases the modularity / extensibility of the code. You should check out the updated docs to understand all of the changes. The new API is similar to the old API, but better.
Through some dark, typescript sorcery, rSchedule no longer needs to export generic objects to adapt the library's typing for different date adapters. Now you can simply import your date adapter of choice once, and the types of rSchedule's objects will automatically be updated. Where before you might have:
const rule = new Rule<typeof MomentDateAdapter>();
const dates: Moment[] = rule
.occurrences()
.toArray()
.map(({ date }) => date);
// OR
const rule = new Rule<typeof StandardDateAdapter>();
const dates: Date[] = rule
.occurrences()
.toArray()
.map(({ date }) => date);
now you simply have
const rule = new Rule();
const dates: Moment[] = rule
.occurrences()
.toArray()
.map(({ date }) => date);
// OR, when using the StandardDateAdapter
const rule = new Rule();
const dates: Date[] = rule
.occurrences()
.toArray()
.map(({ date }) => date);
it's magical! End users need never touch a date adapter.
The @rschedule/rschedule
package has been removed and replaced with @rschedule/core
which itself has been broken up into @rschedule/core
, @rschedule/core/generators
, and @rschedule/core/rules
. The recurrence rule API has also been improved, simplified, and now made public (where before it was private API).
@rschedule/core
contains the required bits of the library: the recurrence and date adapter logic and nothing else (it doesn't contain any actual recurrence rules).@rschedule/core/rules
contains individual rule modules. You can now pick and choose which rules you care about, potentially reducing bundle size. Unused rules are tree-shakable. This also means that this library can add additional rules in the future, without worrying about bloating the library for folks that don't need the new features.@rschedule/core/generators
contains the opinionated OccurrenceGenerator
API, which is also now optional and tree-shakable. This allows additional occurrence stream operators to be added in the future, without fear of bloating the library for folks who don't need them.Note: this update is large and not all changes are included below.
@rschedule/rschedule
-> @rschedule/core
, @rschedule/core/generators
, and @rschedule/core/rules
.OccurrenceGenerator
is no longer generic. Similarly, Calendar
, Schedule
, Rule
, and Dates
only receive an optional generic param for their data
attribute.IDateAdapter
removed and folded into the DateAdapterBase
class. Now, all date adapters must extend the abstract DateAdapterBase
class.DateAdapter
class renamed DateAdapterBase
. DateAdapter
is now an exported type equal to the activated date adapter, as well as a namespace.Dates
duration
constructor argument now only applies the duration to provided dates which do not already have a duration. Put another way, the duration
option for the dates constructor now acts as a default duration for provided dates, rather than the duration of all dates.DateAdapter#duration
type changed from number | undefined
to number
. A duration of 0
is treated as no duration.OccurrenceGenerator#collections()
arguments changed. Specifically, CollectionIterator ICollectionArgs
interface changed.
incrementLinearly
option removedskipEmptyPeriods
option addedgranularity
"INSTANTANIOUS"
option removed. Use "MILLISECONDLY"
instead (which does the same thing).OccurrenceGenerator#collections()
now increments linearly. You can use skipEmptyPeriods: true
to get the old default behavior.OccurrenceGenerator#collections()
is now "YEARLY"
. This change was made to accomidate the other changes to CollectionIterator.@rschedule/json-tools
no longer exports parseJSON()
or serializeToJSON()
functions. Instead, the library contains individual modules for each rSchedule object which, when imported, modify that rschedule object, adding toJSON()
and static fromJSON()
methods.@rschedule/ical-tools
no longer exports parseICal()
or serializeToICal()
functions. Instead, VEvent
now has VEvent#toICal()
and VEvent.fromICal()
.DateAdapter#set('duration', number)
option for setting a date adapters duration.RecurrenceRuleIterator
, as well as individual recurrence rules, are now public API.OccurrenceGenerator#collections()
with granularity "MONTHLY"
and a weekStart
value.OccurrenceGenerator#[Symbol.iterator]
OccurrenceGenerator#firstDate
and OccurrenceGenerator#lastDate
now cache their value after the initial lazy evaluation.Changelog
0.11.6 FEATURE (2019/8/18)
MILLISECONDLY
frequency.Changelog
0.11.0 BREAKING (2019/5/4)
RScheduleConfig
so that config options are namespaced.@rschedule/json-tools
IntersectionOperator#maxFailedIterations
is serialized.
maxFailedIterations
to parseJSON()
.serializeToJSON()
interface has changedparseJSON()
interface has changed to improve typingConstructorReturnType
with typescript builtin InstanceType
DateAdapter#generators
property.DateAdapter#generators
to unknown[]
@rschedule/rule-tools
methods which involved changing the type arguments.@rschedule/rule-tools
package.Rule#options
via Rule#set()
.IScheduleLike<T extends typeof DateAdapter>
interface.IDataContainer<D>
interfaceRScheduleConfig.Rule.defaultWeekStart
config option.Operator.isOperator()
data
property to @rschedule/json-tools
.Schedule
, Calendar
, VEvent
, Dates
, or Rule
object, the generators
property now receives some proper typing. This will make accessing the data
property on occurrence generators easier.isInstance
methods.DateAdapterFor<O extends IOccurrenceGenerator>
DataFor<O extends IDataContainer>
DateAdapter#end
IOccurrenceGenerator#set('timezone')
AddOperator.isAddOperator()
SubtractOperator.isSubtractOperator()
IntersectionOperator.isIntersectionOperator()
UniqueOperator.isUniqueOperator()
OccurrenceStream.isOccurrenceStream()
DateAdapter#date
is immutableundefined
properties in DateAdapter#toJSON()
DateAdapter#generators
is propogated to results