Home Reference Source
import {DateType} from 'tablefilter/src/modules/dateType.js'
public class | source

DateType

Extends:

Feature → DateType

Wrapper for Sugar Date module providing datetime helpers and locales

Constructor Summary

Public Constructor
public

Creates an instance of DateType

Member Summary

Public Members
public

Sugar Date instance

public
public

Global locale

Method Summary

Public Methods
public

Add date time format(s) to a locale as specified by the passed collection of column types, ie: [ 'string', 'number', { type: 'date', locale: 'en', format: ['{dd}/{MM}/{yyyy}']} ]

public

Remove DateType instance

public

getLocale(colIndex: Number): String

Return the locale code for supplied column index as per configuration or global setting

public

getOptions(colIndex: Number, types: Array): Object

Return the type object of a specified column as per configuration or passed collection

public

init()

Initialize DateType instance

public

isValid(dateStr: any, localeCode: any): Boolean

Check string representation of a date for a specified locale is valid

public

parse(dateStr: String, localeCode: String): Date

Parse a string representation of a date for a specified locale and return a date object

Inherited Summary

From class Feature
public

TableFilter configuration

public

TableFilter emitter instance

public

TableFilter feature setting

public

Feature name is the camelised class name as per TableFilter's convention

public

Field indicating whether Feature is initialized

public

TableFilter instance

public

Destroy the feature

public

Disable the feature

public

enable()

Enable the feature

public

init()

Initialize the feature

public

Indicate whether the feature is enabled or not

public

reset()

Reset the feature after being disabled

Public Constructors

public constructor(tf: TableFilter) source

Creates an instance of DateType

Override:

Feature#constructor

Params:

NameTypeAttributeDescription
tf TableFilter

TableFilter instance

Public Members

public datetime: Object source

Sugar Date instance

public initialized: boolean source

Field indicating whether Feature is initialized

Override:

Feature#initialized

public locale: String source

Global locale

Public Methods

public addConfigFormats(types: Array) source

Add date time format(s) to a locale as specified by the passed collection of column types, ie: [ 'string', 'number', { type: 'date', locale: 'en', format: ['{dd}/{MM}/{yyyy}']} ]

Params:

NameTypeAttributeDescription
types Array
  • optional
  • default: []

Collection of column types

public destroy() source

Remove DateType instance

Override:

Feature#destroy

public getLocale(colIndex: Number): String source

Return the locale code for supplied column index as per configuration or global setting

Params:

NameTypeAttributeDescription
colIndex Number

Column index

Return:

String

Locale code (ie: 'en-us')

public getOptions(colIndex: Number, types: Array): Object source

Return the type object of a specified column as per configuration or passed collection

Params:

NameTypeAttributeDescription
colIndex Number

Column index

types Array

Collection of column types, optional

Return:

Object

public init() source

Initialize DateType instance

Override:

Feature#init

public isValid(dateStr: any, localeCode: any): Boolean source

Check string representation of a date for a specified locale is valid

Params:

NameTypeAttributeDescription
dateStr any

String representation of a date

localeCode any

Locale code (ie 'en-us')

Return:

Boolean

public parse(dateStr: String, localeCode: String): Date source

Parse a string representation of a date for a specified locale and return a date object

Params:

NameTypeAttributeDescription
dateStr String

String representation of a date

localeCode String

Locale code (ie 'en-us')

Return:

Date