import ToText , { DateFormatter , GetText } from './totext' ; import parseText from './parsetext' ; import RRule from '../index' ; import { Frequency } from '../types' ; import ENGLISH , { Language } from './i18n' ; /**
 *
 * Implementation of RRule.fromText() and RRule::toText().
 *
 *
 * On the client side, this file needs to be included
 * when those functions are used.
 *
 */ param { String } text return { Object const fromText = function ( text , language = ENGLISH ) { return new RRule ( parseText ( text , language ) || undefined ) ; } ; const 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 ) ; const toText = function ( rrule , gettext ? , language ? , dateFormatter ? ) { return new ToText ( rrule , gettext , language , dateFormatter ) . toString ( ) ; } ; const { isFullyConvertible } = ToText ; export interface Nlp { fromText : typeof fromText ; parseText : typeof parseText ; isFullyConvertible : typeof isFullyConvertible ; toText : typeof toText ; } export { fromText , parseText , isFullyConvertible , toText } ;