当前位置: 首页>>代码示例>>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;未经允许,请勿转载。