logo

/Date Picker|v4.3.3

Class

new Calendar(container, options)index.jsline 84

Create a calendar by DatePicker.createCalendar().

PARAMETERS
NameTypeDescription

container

HTMLElementstring

Container or selector of the Calendar

options

[ Object ]

Calendar options

PROPERTIES
NameTypeDescription

date

Date = newDate()

Initial date (default: today)

type

'date''month''year' = 'date'

Calendar type. Determine whether to show a date, month, or year.

language

string = 'en'

Language code. English('en') and Korean('ko') are provided as default. To use the other languages, use DatePicker.localeTexts.

showToday

boolean = true

Show today.

showJumpButtons

boolean = false

Show the yearly jump buttons (move to the previous and next year in 'date' Calendar)

usageStatistics

boolean = true

Send a hostname to Google Analytics (default: true)

weekStartDay

string = 'Sun'

Start of the week. 'Sun', 'Mon', ..., 'Sat'(default: 'Sun'(start on Sunday))

EXAMPLES
//ES6
import DatePicker from 'tui-date-picker'

// CommonJS
const DatePicker = require('tui-date-picker');

// Browser
const DatePicker = tui.DatePicker;

const calendar = DatePicker.createCalendar('#calendar-wrapper', {
    language: 'en',
    showToday: true,
    showJumpButtons: false,
    date: new Date(),
    type: 'date',
    weekStartDay: 'Mon',
});

calendar.on('draw', (event) => {
    console.log(event.date);
    console.log(event.type);
    for (let i = 0, len = event.dateElements.length; i < len; i += 1) {
        const el = event.dateElements[i];
        const date = new Date(getData(el, 'timestamp'));
        console.log(date);
    }
});

Instance Methods

addCssClass(className)index.jsline 492

Apply a CSS class to the calendar.

PARAMETERS
NameTypeDescription

className

string

Class name

changeLanguage(language)index.jsline 458

Change language.

SEES
PARAMETERS
NameTypeDescription

language

string

Language code. English('en') and Korean('ko') are provided as default.

destroy()index.jsline 507

Destroy the calendar.

draw(options)index.jsline 317

Draw the calendar.

PARAMETERS
NameTypeDescription

options

[ Object ]

Draw options

PROPERTIES
NameTypeDescription

date

[ Date ]

Date to set

type

'date''month''year' = 'date'

Calendar type. Determine whether to show a date, month, or year.

EXAMPLES
calendar.draw();
calendar.draw({
    date: new Date()
});
calendar.draw({
    type: 'month'
});
calendar.draw({
    type: 'month',
    date: new Date()
});

drawNext()index.jsline 372

Draw the next page.

drawPrev()index.jsline 381

Draw the previous page.

getDate()index.jsline 468

Return the rendered date.

RETURNS:
{

Date

}

getDateElements()index.jsline 484

Returns HTML elements for dates.

RETURNS:
{

Array.<HTMLElement>

}

getNextDate()index.jsline 391

Return the next date.

RETURNS:
{

Date

}

getNextYearDate(customStep)index.jsline 416

Return the date a year later.

PARAMETERS
NameTypeDescription

customStep

[ number ]

custom step for getting relative date

RETURNS:
{

Date

}

getPrevDate()index.jsline 403

Return the previous date.

RETURNS:
{

Date

}

getPrevYearDate(customStep)index.jsline 437

Return the date a year previously.

PARAMETERS
NameTypeDescription

customStep

[ number ]

custom step for getting relative date

RETURNS:
{

Date

}

getType()index.jsline 476

Return the calendar's type.

RETURNS:
{

'date''month''year'

}

hide()index.jsline 365

Hide the calendar.

removeCssClass(className)index.jsline 500

Remove a CSS class from the calendar.

PARAMETERS
NameTypeDescription

className

string

Class name

show()index.jsline 358

Show the calendar.

Events

drawindex.jsline 348

Occur after the calendar draws.

SEES
PROPERTIES
NameTypeDescription

date

Date

Calendar date

type

'date''month''year'

Calendar type

dateElements

Array.<HTMLElement>

elements for dates

EXAMPLES
// bind the 'draw' event
calendar.on('draw', ({type, date}) => {
    console.log(`Draw the ${type} calendar and its date is ${date}.`);
});

// unbind the 'draw' event
calendar.off('draw');
Resizable