logo

/repo|v2.1.3

Class

new TZDate(date)

Custom Date Class to handle timezone offset.

PARAMETERS
NameTypeDescription

date

numberTZDateDatestring

date value to be converted. If date is number or string, it should be eligible to parse by Date constructor.

Instance Methods

addDate(d)

Add dates to the instance.

PARAMETERS
NameTypeDescription

d

number

number of days to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

addFullYear(y)

Add years to the instance.

PARAMETERS
NameTypeDescription

y

number

number of years to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

addHours(h)

Add hours to the instance.

PARAMETERS
NameTypeDescription

h

number

number of hours to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

addMilliseconds(ms)

Add milliseconds to the instance.

PARAMETERS
NameTypeDescription

ms

number

number of milliseconds to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

addMinutes(M)

Add minutes to the instance.

PARAMETERS
NameTypeDescription

M

number

number of minutes to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

addMonth(m)

Add months to the instance.

PARAMETERS
NameTypeDescription

m

number

number of months to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

addSeconds(s)

Add seconds to the instance.

PARAMETERS
NameTypeDescription

s

number

number of seconds to be added.

RETURNS:
{

TZDate

} - returns the instance itself.

getDate()

Get the date of the instance.

RETURNS:
{

number

} - date

getDay()

Get the day of the week of the instance.

RETURNS:
{

number

} - day of the week

getFullYear()

Get the year of the instance.

RETURNS:
{

number

} - full year

getHours()

Get the hours of the instance.

RETURNS:
{

number

} - hours

getMilliseconds()

Get the milliseconds of the instance.

RETURNS:
{

number

} - milliseconds

getMinutes()

Get the minutes of the instance.

RETURNS:
{

number

} - minutes

getMonth()

Get the month of the instance. (zero-based)

RETURNS:
{

number

} - month

getSeconds()

Get the seconds of the instance.

RETURNS:
{

number

} - seconds

getTime()

Get milliseconds which is converted by timezone

RETURNS:
{

number

} - milliseconds

getTimezoneOffset()

Get the timezone offset from UTC in minutes.

RETURNS:
{

number

} - timezone offset in minutes.

local(tzValue)

Get the new instance following the system's timezone.
If the system timezone is different from the timezone of the instance,
the instance is converted to the system timezone.

PARAMETERS
NameTypeDescription

tzValue

stringnumber

The name of timezone(IANA name) or timezone offset(in minutes).

RETURNS:
{

TZDate

} - New instance with the system timezone.

setDate(d)

Sets the date of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

d

number

date

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setFullYear(y, m, d)

Sets the year-month-date of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

y

number

year

m

number = this.getMonth()

month (zero-based)

d

number = this.getDate()

date

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setHours(h, M, s, ms)

Sets the hours of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

h

number

hours

M

number = this.getMinutes()

minutes

s

number = this.getSeconds()

seconds

ms

number = this.getMilliseconds()

milliseconds

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setMilliseconds(ms)

Sets the milliseconds of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

ms

number

milliseconds

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setMinutes(M, s, ms)

Sets the minutes of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

M

number

minutes

s

number = this.getSeconds()

seconds

ms

number = this.getMilliseconds()

milliseconds

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setMonth(m, d)

Sets the month of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

m

number

month (zero-based)

d

number = this.getDate()

date

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setSeconds(s, ms)

Sets the seconds of the instance. Equivalent to calling of object.

PARAMETERS
NameTypeDescription

s

number

seconds

ms

number = this.getMilliseconds()

milliseconds

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setTime(t)

Sets the instance to the time represented by a number of milliseconds since 1970-01-01 00:00:00 (UTC+0).

PARAMETERS
NameTypeDescription

t

number

number of milliseconds

RETURNS:
{

number

} - Passed milliseconds of the instance since 1970-01-01 00:00:00 (UTC+0).

setWithRaw(y, m, d, h, M, s, ms)

Set the date and time all at once.

PARAMETERS
NameTypeDescription

y

number

year

m

number

month

d

number

date

h

number

hours

M

number

minutes

s

number

seconds

ms

number

milliseconds

RETURNS:
{

TZDate

} - returns the instance itself.

toDate()

Convert the instance to the native object.

RETURNS:
{

Date

} - The native object.

toString()

Get the string representation of the date.

RETURNS:
{

string

} - string representation of the date.

tz(tzValue)

Set the timezone offset of the instance.

PARAMETERS
NameTypeDescription

tzValue

stringnumber

The name of timezone(IANA name) or timezone offset(in minutes).

RETURNS:
{

TZDate

} - New instance with the timezone offset.

valueOf()

Get the value of the date. (milliseconds since 1970-01-01 00:00:00 (UTC+0))

RETURNS:
{

number

} - value of the date.
Resizable