當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript moment.weekdays函數代碼示例

本文整理匯總了TypeScript中moment.weekdays函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript weekdays函數的具體用法?TypeScript weekdays怎麽用?TypeScript weekdays使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了weekdays函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: moment

 .config(($mdDateLocaleProvider: angular.material.IDateLocaleProvider) => {
     $mdDateLocaleProvider.parseDate = (dateString: string) => {
         console.log(dateString);
         let m = moment(dateString, 'DD.MM.YYYY', true);
         return m.isValid() ? m.utc().toDate() : new Date(NaN);
     };
     $mdDateLocaleProvider.formatDate = (date: Date) => {
         if (date === undefined || date ===  null)
             return null;
         return moment(date).format('DD.MM.YYYY');
     };
     $mdDateLocaleProvider.months = moment.months();
     $mdDateLocaleProvider.shortMonths = moment.monthsShort();
     $mdDateLocaleProvider.days = moment.weekdays();
     $mdDateLocaleProvider.shortDays = moment.weekdaysShort();
     $mdDateLocaleProvider.firstDayOfWeek = 1;
 })
開發者ID:pharmscription,項目名稱:com.pharmscription.Frontend,代碼行數:17,代碼來源:app.ts

示例2:

			const getWeekDays = () => moment.weekdays().map((day: string, i: number) => localeDate.clone().startOf('week').add(i, 'day').format('dd'));
開發者ID:Bhaskar0812,項目名稱:angular-moment-picker,代碼行數:1,代碼來源:locale.ts

示例3: Promise

        return new Promise(resolve => {
            let date = moment(cordysDate, 'YYYY/MM/DDTHH:mm:ss.SSS');
            if (cordysDate.indexOf('T') < 0) {
                date = moment(cordysDate, 'YYYY/MM/DD HH:mm:ss');
            }

            // clone date and set 12:00 am
            let dateWithoutTime = moment(date).startOf('day');
            // today 12:00 am
            let nowWithoutTime = moment().startOf('day');

            // after today 12:00 am
            if (nowWithoutTime.isSame(dateWithoutTime)) {
                if (hideTime) {
                    this.translate.get('app.date.today').subscribe(message => {
                        resolve(message);
                    });
                } else {
                    resolve(date.fromNow());
                }
            }

            // after yesterday 12:00 am
            // 昨日 12:00 / 昨天 12:00 / Yesterday 12:00
            if (moment(nowWithoutTime).subtract(1, 'days').isSame(dateWithoutTime)) {
                this.translate.get('app.date.yesterday').subscribe(message => {
                    if (hideTime) {
                        resolve(message);
                    } else {
                        resolve(message + date.format('H:mm'));
                    }
                });
            }

            // yesterday 12:00am ~ last week 12:00 am
            // X曜日 / 星期X / Mon.
            if (moment(nowWithoutTime).subtract(1, 'days').isAfter(dateWithoutTime) &&
                (moment(nowWithoutTime).subtract(7, 'days').isSame(dateWithoutTime) ||
                    moment(nowWithoutTime).subtract(7, 'days').isBefore(dateWithoutTime))) {
                resolve(moment.weekdays(date.day()));
            }

            // 182days(half of a year) before 12:00am ~ last week 12:00 am
            // M月d日 / M月d日 / Mnd/d
            if (moment(nowWithoutTime).subtract(7, 'days').isAfter(dateWithoutTime) &&
                (moment(nowWithoutTime).subtract(182, 'days').isSame(dateWithoutTime) ||
                    moment(nowWithoutTime).subtract(182, 'days').isBefore(dateWithoutTime))) {
                let parameter = {
                    'MM': (date.month() + 1),
                    'DD': date.date()
                };
                this.translate.get('app.date.MMDD', parameter).subscribe(message => {
                    resolve(message);
                });
            }

            // 183days before 12:00am
            if (moment(nowWithoutTime).subtract(182, 'days').isAfter(dateWithoutTime)) {
                let parameter = {
                    'YYYY': date.year(),
                    'MM': (date.month() + 1)
                };
                this.translate.get('app.date.YYYYMM', parameter).subscribe(message => {
                    resolve(message);
                });
            }
        });
開發者ID:intasect,項目名稱:intalinx-mobile,代碼行數:67,代碼來源:dateutil.ts

示例4: weekdays

 public weekdays(number): string {
     return moment.weekdays(number);
 }
開發者ID:rlasjunies,項目名稱:kct,代碼行數:3,代碼來源:days-encoding.ts

示例5: getWeekday

 getWeekday(dateString: string) {
   return moment.weekdays(moment(dateString).day());
 }
開發者ID:Meistercoach83,項目名稱:sfw,代碼行數:3,代碼來源:calendar.service.ts


注:本文中的moment.weekdays函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。