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


TypeScript DeprecatedDatePipe.transform方法代碼示例

本文整理匯總了TypeScript中@angular/common.DeprecatedDatePipe.transform方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DeprecatedDatePipe.transform方法的具體用法?TypeScript DeprecatedDatePipe.transform怎麽用?TypeScript DeprecatedDatePipe.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/common.DeprecatedDatePipe的用法示例。


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

示例1: expectDateFormatAs

 // Check the transformation of a date into a pattern
 function expectDateFormatAs(date: Date | string, pattern: any, output: string): void {
   // disabled on chrome mobile because of the following bug affecting the intl API
   // https://bugs.chromium.org/p/chromium/issues/detail?id=796583
   // the android 7 emulator of saucelabs uses chrome mobile 63
   if (!browserDetection.isAndroid && !browserDetection.isWebkit) {
     expect(pipe.transform(date, pattern)).toEqual(output);
   }
 }
開發者ID:Cammisuli,項目名稱:angular,代碼行數:9,代碼來源:date_pipe_spec.ts

示例2: it

      it('should format each component correctly', () => {
        const dateFixtures: any = {
          'y': '2015',
          'yy': '15',
          'M': '6',
          'MM': '06',
          'MMM': 'Jun',
          'MMMM': 'June',
          'd': '15',
          'dd': '15',
          'EEE': 'Mon',
          'EEEE': 'Monday'
        };

        const isoStringWithoutTimeFixtures: any = {
          'y': '2015',
          'yy': '15',
          'M': '1',
          'MM': '01',
          'MMM': 'Jan',
          'MMMM': 'January',
          'd': '1',
          'dd': '01',
          'EEE': 'Thu',
          'EEEE': 'Thursday'
        };

        if (!browserDetection.isOldChrome) {
          dateFixtures['h'] = '9';
          dateFixtures['hh'] = '09';
          dateFixtures['j'] = '9 AM';
          isoStringWithoutTimeFixtures['h'] = '12';
          isoStringWithoutTimeFixtures['hh'] = '12';
          isoStringWithoutTimeFixtures['j'] = '12 AM';
        }

        // IE and Edge can't format a date to minutes and seconds without hours
        if (!browserDetection.isEdge && !browserDetection.isIE ||
            !browserDetection.supportsNativeIntlApi) {
          if (!browserDetection.isOldChrome) {
            dateFixtures['HH'] = '09';
            isoStringWithoutTimeFixtures['HH'] = '00';
          }
          dateFixtures['E'] = 'M';
          dateFixtures['L'] = 'J';
          dateFixtures['m'] = '3';
          dateFixtures['s'] = '1';
          dateFixtures['mm'] = '03';
          dateFixtures['ss'] = '01';
          isoStringWithoutTimeFixtures['m'] = '0';
          isoStringWithoutTimeFixtures['s'] = '0';
          isoStringWithoutTimeFixtures['mm'] = '00';
          isoStringWithoutTimeFixtures['ss'] = '00';
        }

        Object.keys(dateFixtures).forEach((pattern: string) => {
          expectDateFormatAs(date, pattern, dateFixtures[pattern]);
        });

        if (!browserDetection.isOldChrome) {
          Object.keys(isoStringWithoutTimeFixtures).forEach((pattern: string) => {
            expectDateFormatAs(
                isoStringWithoutTime, pattern, isoStringWithoutTimeFixtures[pattern]);
          });
        }

        expect(pipe.transform(date, 'Z')).toBeDefined();
      });
開發者ID:Cammisuli,項目名稱:angular,代碼行數:68,代碼來源:date_pipe_spec.ts

示例3: expect

 () => expect(() => pipe.transform({})).toThrowError(/InvalidPipeArgument/));
開發者ID:Cammisuli,項目名稱:angular,代碼行數:1,代碼來源:date_pipe_spec.ts


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