• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript moment-timezone.tz函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中moment-timezone.tz函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tz函数的具体用法?TypeScript tz怎么用?TypeScript tz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tz函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: transform

  transform(value: any, timezoneFrom?: string, timezoneTo?: string): string {
    if (typeof value === 'string') {
      value = parseInt(value, 10);

      if (isNaN(value)) {
        return '';
      }
    }

    if (typeof value !== 'number' && !(value instanceof Date) && !moment.isMoment(value)) {
      return '';
    }

    if (!timezoneFrom) {
      return typeof value === 'number'
        ? this.hourToString(value)
        : moment.utc(value).format('HH:mm');
    } else {
      timezoneTo = timezoneTo ? timezoneTo : moment.tz.guess();

      return moment
        .tz(
          typeof value === 'number'
            ? this.hourToString(value)
            : moment.utc(value).format('HH:mm'),
          'HH:mm',
          timezoneFrom
        )
        .tz(timezoneTo)
        .format('HH:mm');
    }
  }
开发者ID:Sirimangalo,项目名称:meditation-plus-angular,代码行数:32,代码来源:hour.pipe.ts


示例2: isNearTo5PM

    public isNearTo5PM(fromPage:string):boolean{
        var nearTo5PMFlag:boolean = false;
        let dt = moment.now();
        let now = moment.tz(dt, 'America/Chicago');

        var hour:number = now.hour();
        var minute:number = now.minute();
        var dayOfWeek:number = now.day();
        LoggerUtil.info("Hour:::"+hour +" :::minute:::"+minute + " :::dayOfWeek:::"+dayOfWeek)

        if(CommonUtil.isNotBlank(fromPage) && CommonUtil.equalsIgnoreCase(fromPage,"StartService")){
            if((dayOfWeek != 0 )&& (((hour == 16)&& (minute >=30 && minute <=45)))) {
                nearTo5PMFlag = true;
            } else {
                nearTo5PMFlag = false;
            }
            LoggerUtil.info("nearTo5PMFlag in dateUtil::"+nearTo5PMFlag)
        }else if(CommonUtil.isNotBlank(fromPage) && CommonUtil.equalsIgnoreCase(fromPage,"Verify")){
            if((dayOfWeek != 0 )&& (((hour == 16)&& (minute >=45)) || (hour > 16)))  {
                nearTo5PMFlag = true;
            } else {
                nearTo5PMFlag = false;
            }
        }
        return nearTo5PMFlag;
    }
开发者ID:bbachi,项目名称:Angular5Sample,代码行数:26,代码来源:date.util.ts


示例3: getTimeStamp

    public getTimeStamp(): string {

        let dt = moment.now();
        let newDate= moment.tz(dt, 'America/Chicago').format("MM/DD/YYYY HH:mm:ss")
        //console.log("date TS for logs:::" +newDate)
        return newDate;

    }
开发者ID:bbachi,项目名称:Angular5Sample,代码行数:8,代码来源:date.util.ts


示例4: it

 it('should format date/moment objects correctly', () => {
   expect(pipe.transform(new Date(Date.UTC(2017,  9, 26, 10, 10, 0)))).toBe('10:10');
   expect(pipe.transform(new Date('2014-06-01T00:06:00Z'))).toBe('00:06');
   expect(pipe.transform(new Date('2014-06-01T23:59:00Z'))).toBe('23:59');
   expect(pipe.transform(moment('2014-06-01T23:59:00Z'))).toBe('23:59');
   expect(pipe.transform(moment.utc('2014-06-01T23:59:00Z'))).toBe('23:59');
   expect(pipe.transform(moment.tz('2014-06-01T23:59:00Z', 'Asia/Tokyo'))).toBe('23:59');
 });
开发者ID:Sirimangalo,项目名称:meditation-plus-angular,代码行数:8,代码来源:hour.pipe.spec.ts


示例5: timezoneOffset

 /** Get offset of timezone */
 timezoneOffset(zone: string): string {
   let offset = moment.tz(zone).utcOffset();
   const neg = offset < 0;
   if (neg) {
     offset = -1 * offset;
   }
   const hours = Math.floor(offset / 60);
   const minutes = (offset / 60 - hours) * 60;
   let sym = neg ? '-' : '+';
   let paddedHours = this.pad(hours.toString());
   let paddedMinutes = this.pad(minutes.toString());
   return '(GMT' + sym + paddedHours + ':' + paddedMinutes + ')';
 }
开发者ID:bluecaret,项目名称:carettab,代码行数:14,代码来源:timezone.service.ts


示例6: createEvent

function createEvent(attrs: {
  id: string | number,
  start: string,
  duration: number,
  timezone?: string,
  allDay?: boolean,
}) {
  let tz = attrs.timezone || 'US/Pacific';
  return {
    id: attrs.id,
    start: moment.tz(attrs.start, 'YYYY-MM-DD HH:mm', tz),
    duration: attrs.duration || 60,
  };
}
开发者ID:lehresman,项目名称:callay-engine,代码行数:14,代码来源:engine.spec.ts


示例7: respond

    public respond() {
      const londonDate = new Date();
      const lvivDate = moment.tz(londonDate, 'Europe/Kiev');

      this._callback([{
          "color": global['hexGenerator'](),
          "fields": [
            {
              "title": 'London (GB)',
              "value": `${this._padNumber(londonDate.getDate())} ${this.months[londonDate.getMonth()]} ${londonDate.getFullYear()}, ${this._padNumber(londonDate.getHours())}:${this._padNumber(londonDate.getMinutes())}`,
              "short": true
            },
            {
              "title": 'Lviv (UKR)',
              "value": `${lvivDate.format('DD')} ${this.months[parseInt(lvivDate.format('M'), 10)]} ${lvivDate.format('YYYY')}, ${lvivDate.format('HH')}:${lvivDate.format('mm')}`,
              "short": true
            }
          ],
          "image_url": 'http://benderthebot.herokuapp.com/icons/time.png'
      }]);
    }
开发者ID:SlimDogs,项目名称:bender-slack-bot,代码行数:21,代码来源:callback.ts


示例8: Promise

  return new Promise(function (resolve, reject) {
    let localDB=PouchDB(localdb);
    let partialsDB=PouchDB(partialsdb+'_'+data.uid+'_year',{auto_compaction: true});



    let dateDay=parseInt(data.date[6]+data.date[7]);
    let dateMonth=parseInt(data.date[4]+data.date[5]);
    let dateforYear=parseInt(data.date[0]+data.date[1]+data.date[2]+data.date[3]);

    let dateBeginningOfDay=moment.tz(dateforYear+' '+dateMonth+' '+dateDay,"YYYY MM DD",timezone).valueOf();
    let dateBeginningOfMonth=moment.tz(dateforYear+' '+dateMonth+' 01',"YYYY MM DD",timezone).valueOf();
    let dateBeginningOfYear=moment.tz(dateforYear+' 01 01',"YYYY MM DD",timezone).valueOf();

    let dateforDay=parseInt(dateforYear+data.date[4]+data.date[5]+dateDay);
    let dateforMonth=parseInt(dateforYear+data.date[4]+data.date[5]);




        partialsDB.get('yearly_'+data.uid).then(function(yearPower){


          if( yearPower.dateBeginningOfYear != dateBeginningOfYear ){



            let yearlynew={
              _id:'yearly_'+data.uid+'_'+yearPower.dateforYear,
              power:yearPower.power,
              updatedAt:yearPower.dateBeginningOfYear
            };

            localDB.put(yearlynew).then(function(doc){

              yearPower.power=data.yearlyEnergy;
              yearPower.dateBeginningOfYear=dateBeginningOfYear;
              yearPower.dateforYear=dateforYear;


              partialsDB.destroy().then(function(){
                let partialsDB=PouchDB(partialsdb+'_'+data.uid+'_year',{auto_compaction: true});

                delete yearPower._rev
              partialsDB.put(yearPower).then(function(){

                resolve(true);
              }).catch(function(err){
                reject(err);
              });
});

            }).catch(function(err){
reject(err);
            });

          } else{
            yearPower.power=data.yearlyEnergy;
            yearPower.dateBeginningOfYear=dateBeginningOfYear;
            yearPower.dateforYear=dateforYear;
            partialsDB.destroy().then(function(){
              let partialsDB=PouchDB(partialsdb+'_'+data.uid+'_year',{auto_compaction: true});

              delete yearPower._rev
            partialsDB.put(yearPower).then(function(){

              resolve(true);
            }).catch(function(err){
              reject(err);
            });
  });
          }



        }).catch(function(){
          let yearly={
            _id:'yearly_'+data.uid,
            dateBeginningOfYear:dateBeginningOfYear,
            power:data.yearlyEnergy,
            dateforYear:dateforYear
          };
          partialsDB.put(yearly).then(function(){

            resolve(true);
          }).catch(function(err){
            reject(err);
          });
        });




})
开发者ID:dottgonzo,项目名称:express-autoaurora,代码行数:94,代码来源:setpowerpartials.ts


示例9:

 ]).spread((time, general) => {
     return moment.tz(time.system_time.$date, general.timezone).format('Z');
 });
开发者ID:mactanxin,项目名称:gui,代码行数:3,代码来源:system-repository.ts


示例10: prodStartTasks

});

router.post("/stale", (req, res, next) => {
    prodStartTasks()
    .then(() => logger.info(`Finished running recover job`))
    .then(() => res.send("OK"))
    .catch((err) => {
        logger.error(err);
        res.sendStatus(500);
    });
});

const now = moment().tz(TIME_ZONE);
const timeFormat = "HH:mm";
for (let job of jobSchedule) {
    const startTime = moment.tz(job.startTime, timeFormat, TIME_ZONE);
    const endTime = moment.tz(job.endTime, timeFormat, TIME_ZONE);
    const correctTime = now.isBetween(startTime, endTime);
    const correctDay = job.weekdays.includes(now.weekday());
    if (!correctDay) {
        logger.info(`not correct day (${now.weekday()}) to run job: ${job.name}`);
        continue;
    }
    if (!correctTime) {
        logger.info(`not correct time (${now.format(timeFormat)}) to run job: ${job.name}`);
        continue;
    }
    if (!job.enabled) {
        logger.info(`Job is disabled: ${job.name}`);
        continue;
    }
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:31,代码来源:index.ts


示例11: describe

describe('monthLayoutFor', () => {
  let tz = 'Europe/Berlin';
  let startDate = moment.tz('2018-01-01 00:00', tz);
  let endDate = moment.tz('2018-01-15 00:00', tz);

  it('should properly position a single event', () => {
    let events: TestEvent[] = [new TestEvent({start: '2018-01-01 08:00', duration: 60})];
    let weeks = monthLayoutFor(startDate, endDate, events);

    expect(weeks.length).toBe(3);
    expect(weeks[0].days[1].dateStr).toBe('2018-01-01');
    expect(weeks[0].days[1].entries.length).toBe(1);
    expect(weeks[0].days[1].entries[0].isStart).toBe(true);
    expect(weeks[0].days[1].entries[0].isEnd).toBe(true);
  });

  it('should properly position the levels for multiple events', () => {
    let events: TestEvent[] = [
      new TestEvent({start: '2018-01-02 14:00', duration: 60}), // will not be added to 2018-01-01
      new TestEvent({start: '2018-01-01 10:15', duration: 60}),
      new TestEvent({start: '2018-01-01 08:00', duration: 60}),
    ];
    let weeks = monthLayoutFor(startDate, endDate, events);
    expect(weeks[0].days[1].entries.length).toBe(2);
    expect(weeks[0].days[1].entries[0].originalEvent.start.hours()).toBe(8);
    expect(weeks[0].days[1].entries[0].level).toBe(0);
    expect(weeks[0].days[1].entries[1].originalEvent.start.hours()).toBe(10);
    expect(weeks[0].days[1].entries[1].level).toBe(1);
  });

  it('should properly calculate spanning events in the same week', () => {
    let firstEvent = new TestEvent({start: '2018-01-02 14:00', duration: 60});
    let secondEvent = new TestEvent({start: '2018-01-01 10:15', duration: 60*48});
    let thirdEvent = new TestEvent({start: '2018-01-01 08:00', duration: 60});
    let fourthEvent = new TestEvent({start: '2018-01-03 08:00', duration: 30});
    let fifthEvent = new TestEvent({start: '2018-01-03 09:00', duration: 30});
    let events: TestEvent[] = [firstEvent, secondEvent, thirdEvent, fourthEvent, fifthEvent];
    let weeks = monthLayoutFor(startDate, endDate, events);

    // 2018-01-01
    expect(weeks[0].days[1].entries.length).toBe(2);

    expect(weeks[0].days[1].entries[0].id).toBe(thirdEvent.id);
    expect(weeks[0].days[1].entries[0].isStart).toBe(true);
    expect(weeks[0].days[1].entries[0].isEnd).toBe(true);
    expect(weeks[0].days[1].entries[0].level).toBe(0);
    expect(weeks[0].days[1].entries[0].span).toBe(1);

    expect(weeks[0].days[1].entries[1].id).toBe(secondEvent.id);
    expect(weeks[0].days[1].entries[1].isStart).toBe(true);
    expect(weeks[0].days[1].entries[1].isEnd).toBe(true);
    expect(weeks[0].days[1].entries[1].level).toBe(1);
    expect(weeks[0].days[1].entries[1].span).toBe(3);

    // 2018-01-02
    expect(weeks[0].days[2].entries.length).toBe(1);

    expect(weeks[0].days[2].entries[0].id).toBe(firstEvent.id);
    expect(weeks[0].days[2].entries[0].level).toBe(0);
    expect(weeks[0].days[2].entries[0].span).toBe(1);

    // 2018-01-03
    expect(weeks[0].days[3].entries.length).toBe(2);

    expect(weeks[0].days[3].entries[0].id).toBe(fourthEvent.id);
    expect(weeks[0].days[3].entries[0].level).toBe(0);
    expect(weeks[0].days[3].entries[0].span).toBe(1);

    expect(weeks[0].days[3].entries[1].id).toBe(fifthEvent.id);
    expect(weeks[0].days[3].entries[1].level).toBe(2);
    expect(weeks[0].days[3].entries[1].span).toBe(1);
  });

  it('should properly span multi-day events across two weeks', () => {
    let longEvent = new TestEvent({start: '2018-01-06 10:15', duration: 60*24*4});
    let events: TestEvent[] = [
      new TestEvent({start: '2018-01-06 09:00', duration: 30}),
      longEvent,
      new TestEvent({start: '2018-01-07 09:00', duration: 30}),
    ];
    let weeks = monthLayoutFor(startDate, endDate, events);

    // 2018-01-06 (Saturday)
    expect(weeks[0].days[6].entries.length).toBe(2);
    expect(weeks[0].days[6].entries[0].id).not.toBe(longEvent.id);
    expect(weeks[0].days[6].entries[1].id).toBe(longEvent.id);
    expect(weeks[0].days[6].entries[1].span).toBe(1); // 1 because only 1 day left this week
    expect(weeks[0].days[6].entries[1].isStart).toBe(true);
    expect(weeks[0].days[6].entries[1].isEnd).toBe(false);

    // 2018-01-07 (Sunday)
    expect(weeks[1].days[0].entries.length).toBe(2);
    expect(weeks[1].days[0].entries[0].id).not.toBe(longEvent.id);
    expect(weeks[1].days[0].entries[1].id).toBe(longEvent.id);
    expect(weeks[1].days[0].entries[1].span).toBe(4);
    expect(weeks[1].days[0].entries[1].isStart).toBe(false);
    expect(weeks[1].days[0].entries[1].isEnd).toBe(true);

    // 2018-01-09 (Tuesday)
    // Even though longEvent spans through Tuesday, the entry is added
//.........这里部分代码省略.........
开发者ID:lehresman,项目名称:callay-engine,代码行数:101,代码来源:engine.spec.ts


示例12: constructor

 constructor(attrs: any) {
   this.id = uuid();
   this.start = moment.tz(attrs.start, attrs.timezone || 'Europe/Berlin');
   this.duration = attrs.duration;
   this.isAllDay = attrs.isAllDay || false;
 }
开发者ID:lehresman,项目名称:callay-engine,代码行数:6,代码来源:engine.spec.ts



注:本文中的moment-timezone.tz函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript moment-timezone.utc函数代码示例发布时间:2022-05-25
下一篇:
TypeScript moment-timezone.duration函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap