How to use the moment-timezone/builds/moment-timezone-with-data-2012-2022.min function in moment-timezone

To help you get started, we’ve selected a few moment-timezone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static computeTransactionDate(formDate: Date, txDate: Date, tz: string): Date {
    if(!formDate || !formDate.getTime()) {
      return txDate;
    }

    let formMoment = moment(formDate).tz(tz || defaultTz);
    let txMoment = moment(txDate).tz(tz || defaultTz);

    // make the time be at the very end of the day
    formMoment.hours(23);
    formMoment.minutes(59);
    formMoment.seconds(59);
    formMoment.milliseconds(999);

    let sameDay = formMoment.year() === txMoment.year() &&
      formMoment.month() === txMoment.month() &&
      formMoment.date() === txMoment.date();

    if(sameDay) {
      return txDate;
    }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static getDateFromLocalDateString(input: string, tz: string) {
    let parts = input.split('-');

    let m = moment().tz(tz || defaultTz);
    m.hours(0);
    m.minutes(0);
    m.seconds(0);
    m.milliseconds(0);
    m.year(parseInt(parts[0]));
    m.month(parseInt(parts[1]) - 1);
    m.date(parseInt(parts[2]));

    return m.toDate();
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static setBeginOfDay(input: Date, tz: string) {
    let m = moment(input).tz(tz || defaultTz);

    m.hours(0);
    m.minutes(0);
    m.seconds(0);
    m.milliseconds(0);
    input.setTime(m.valueOf());
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static getPeriodStart(tz: string): Date {
    let m = moment().tz(tz || defaultTz);
    m.date(1);
    m.hours(0);
    m.minutes(0);
    m.seconds(0);
    m.milliseconds(0);

    return m.toDate();
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static setEndOfDay(input: Date, tz: string) {
    let m = moment(input).tz(tz || defaultTz);

    m.hours(23);
    m.minutes(59);
    m.seconds(59);
    m.milliseconds(999);
    input.setTime(m.valueOf());
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static isSameDay(date1: Date, date2: Date, tz: string) {
    let m1 = moment(date1).tz(tz || defaultTz);
    let m2 = moment(date2).tz(tz || defaultTz);

    return m1.year() === m2.year() &&
      m1.month() === m2.month() &&
      m1.date() === m2.date();
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static getLocalDateString(input: Date, tz: string) {
    let m = moment(input).tz(tz || defaultTz);

    let year = m.format('YYYY');
    let month = m.format('MM');
    let date = m.format('DD');

    if(month.length < 2) {
      month = '0' + month;
    }

    if(date.length < 2) {
      date = '0' + date;
    }

    return year + '-' + month + '-' + date;
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static isSameDay(date1: Date, date2: Date, tz: string) {
    let m1 = moment(date1).tz(tz || defaultTz);
    let m2 = moment(date2).tz(tz || defaultTz);

    return m1.year() === m2.year() &&
      m1.month() === m2.month() &&
      m1.date() === m2.date();
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static getLocalDateStringExcl(input: Date, tz: string) {
    let m = moment(input.getTime() - 1).tz(tz || defaultTz);

    let year = m.format('YYYY');
    let month = m.format('MM');
    let date = m.format('DD');

    if(month.length < 2) {
      month = '0' + month;
    }

    if(date.length < 2) {
      date = '0' + date;
    }

    return year + '-' + month + '-' + date;
  }
github openaccounting / oa-web / src / app / shared / dateutil.ts View on Github external
static getOneMonthLater(input: Date, tz: string): Date {
    let m = moment(input).tz(tz || defaultTz);

    m.month(m.month() + 1);

    return m.toDate();
  }