Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( InvalidExprError = errors.New("invalid expression") InvalidExprSecondError = errors.New("invalid expression, second part") InvalidExprMinuteError = errors.New("invalid expression, minute part") InvalidExprHourError = errors.New("invalid expression, hour part") InvalidExprDayOfMonthError = errors.New("invalid expression, day of month part") InvalidExprMonthError = errors.New("invalid expression, month part") InvalidExprDayOfWeekError = errors.New("invalid expression, day of week part") InvalidExprYearError = errors.New("invalid expression, year part") )
Functions ¶
This section is empty.
Types ¶
type ExpressionDescriptor ¶
type ExpressionDescriptor struct {
// contains filtered or unexported fields
}
ExpressionDescriptor represents the CRON expression descriptor.
func NewDescriptor ¶
func NewDescriptor(options ...Option) (exprDesc *ExpressionDescriptor, err error)
NewDescriptor returns a new CRON expression descriptor based on the list of options. If no options provided, a default CRON expression descriptor will be returned instead. By default, English (Locale_en) will always be loaded.
func (*ExpressionDescriptor) ToDescription ¶
func (e *ExpressionDescriptor) ToDescription(expr string, loc LocaleType) (desc string, err error)
ToDescription converts the CRON expression to the human readable string in specified locale. If the specified locale had not been loaded by the CRON expression descriptor, the result will be returned in English (Locale_en) by default.
To configure supported locales of the CRON expression descriptor, please see the SetLocales() option.
type Locale ¶
type Locale interface { GetLocaleType() (typ LocaleType) GetBool(key LocaleKey) (value bool) GetString(key LocaleKey) (value string) GetSlice(key LocaleKey) (values []string) }
Locale is the interface to a specific i18n. The methods of Locale interface returns the corresponding i18n of a specific key.
func NewLocaleLoaders ¶
func NewLocaleLoaders(types ...LocaleType) (loaders []Locale, err error)
type LocaleLoader ¶
type LocaleLoader struct {
// contains filtered or unexported fields
}
LocaleLoader holds the map of i18n strings in a specific language (localType).
func (*LocaleLoader) GetBool ¶
func (l *LocaleLoader) GetBool(key LocaleKey) (value bool)
func (*LocaleLoader) GetLocaleType ¶
func (l *LocaleLoader) GetLocaleType() (typ LocaleType)
func (*LocaleLoader) GetSlice ¶
func (l *LocaleLoader) GetSlice(key LocaleKey) (values []string)
func (*LocaleLoader) GetString ¶
func (l *LocaleLoader) GetString(key LocaleKey) (value string)
type LocaleType ¶
type LocaleType string
const ( LocaleAll LocaleType = "all" Locale_cs LocaleType = "cs" Locale_da LocaleType = "da" Locale_de LocaleType = "de" Locale_en LocaleType = "en" Locale_es LocaleType = "es" Locale_fa LocaleType = "fa" Locale_fi LocaleType = "fi" Locale_fr LocaleType = "fr" Locale_he LocaleType = "he" Locale_it LocaleType = "it" Locale_ja LocaleType = "ja" Locale_ko LocaleType = "ko" Locale_nb LocaleType = "nb" Locale_nl LocaleType = "nl" Locale_pl LocaleType = "pl" Locale_pt_BR LocaleType = "pt_BR" Locale_ro LocaleType = "ro" Locale_ru LocaleType = "ru" Locale_sk LocaleType = "sk" Locale_sl LocaleType = "sl" Locale_sv LocaleType = "sv" Locale_sw LocaleType = "sw" Locale_tr LocaleType = "tr" Locale_uk LocaleType = "uk" Locale_zh_CN LocaleType = "zh_CN" Locale_zh_TW LocaleType = "zh_TW" )
func ParseLocale ¶ added in v0.0.3
func ParseLocale(s string) (l LocaleType, err error)
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger is the logging interface for expression descriptor.
type Option ¶
type Option func(exprDesc *ExpressionDescriptor)
Option allows to configure expression descriptor.
func DayOfWeekStartsAtOne ¶
DayOfWeekStartsAtOne configures first day of the week is Monday (index 1) or Sunday (index 0, default).
func SetLocales ¶
func SetLocales(locales ...LocaleType) Option
SetLocales initializes the list of initial locales that the expression descriptor will output in. By default, the expression descriptor always initialize English (Locale_en).
func Use24HourTimeFormat ¶
Use24HourTimeFormat configures the expression descriptor to output time in 24-hour format (14:00) or 12-hour format (2PM, default).