Nonconformist Propaganda Machine

    date-tz

    0.1.2 • Public • Published

    constructor

    Wrapper above js native Date object for using with time zones that differs from current

    Parameters

    • zone string zone (optional, default '+0000')
    • args any any data to initialize native date object

    Examples

    import DateTz from 'DateTz';
    const date = new DateTz('+0300', '2000-01-01T00:00:00.000Z');
    i.toISOString(); // '2000-01-01T00:00:00.000Z'

    zone

    Parameters

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('+0000', '2000-01-01T00:00:00.000Z');
    i.zone // '+0000';
    i.getTzHours(); // 0
    i.getUTCHours(); // 0
    i.zone = '+0300';
    i.zone; // '+0300'
    i.getTzHours(); // 3
    i.getUTCHours(); // 0

    getTzDate

    returns date in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('+06', '2000-01-10T00:00:00.000+06:00');
    i.setTzDate(12);
    i.getTzDate(); // 12
    i.getUTCDate(); // 13

    Returns number

    getTzDay

    returns day of week in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('06', '2000-01-10T00:00:00.000+06:00');
    i.setTzDate(12);
    i.getTzDay(); // 3
    i.getUTCDay(); // 2

    Returns number

    getTzFullYear

    returns year in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('+06', '2000-01-01T00:00:00.000+06:00');
    i.setTzFullYear(2002);
    i.getTzFullYear(); // 2002
    i.getUTCFullYear(); // 2001

    Returns number

    getTzHours

    returns hours in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('-06', '2000-01-01T06:00:00.000Z');
    i.getTzHours(); // 0
    i.setTzHours(2);
    i.getTzHours(); // 2
    i.getUTCHours(); // 8;

    Returns number

    getTzMilliseconds

    returns milliseconds in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('-06', '2000-01-01T00:00:00.000Z');
    i.setTzMilliseconds(15);
    i.getTzMilliseconds(); // 15
    i.getUTCMilliseconds(); // 15

    Returns number

    getTzMinutes

    returns minutes in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('-0603', '2000-01-01T06:00:00.000Z');
    i.setTzMinutes(15);
    i.getTzMinutes(); // 15
    i.getUTCMinutes(); // 18

    Returns number

    getTzMonth

    returns month in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('-06', '2000-01-30T20:00:00.000-06:00');
    i.setTzMonth(5);
    i.getTzMonth(); // 5
    i.getUTCMonth(); // 6

    Returns number

    getTzSeconds

    returns seconds in zone

    Examples

    import DateTz from 'DateTz';
    const i = new DateTz('-06', '2000-01-01T00:00:00.000Z');
    i.setTzMilliseconds(15);
    i.getTzMilliseconds(); // 15
    i.getUTCMilliseconds() // 15

    Returns number

    getTzTimezoneOffset

    returns offset between zone and UTC

    Examples

    import DateTz from 'DateTz';
    = new DateTz('-0507', '2000-01-30T20:00:00.000-06:00');
    i.getTzTimezoneOffset(); // 307

    Returns number

    setTzDate

    set date in zone

    setTzFullYear

    set year in zone

    setTzHours

    set hours in zone

    setTzMilliseconds

    set milliseconds in zone

    setTzMinutes

    set minutes in zone

    setTzMonth

    set month in zone

    setTzSeconds

    set seconds in zone

    Installation

    npm install --save DateTz

    Install

    npm i date-tz

    DownloadsWeekly Downloads

    604

    Version

    0.1.2

    License

    ISC

    Unpacked Size

    201 kB

    Total Files

    10

    Last publish

    Collaborators

    • a.chepugov