ng-zorro-antd-core-pipe.mjs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import * as i0 from '@angular/core';
  2. import { Pipe, NgModule } from '@angular/core';
  3. import { timeUnits } from 'ng-zorro-antd/core/time';
  4. import { padStart } from 'ng-zorro-antd/core/util';
  5. /**
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  8. */
  9. class NzTimeRangePipe {
  10. transform(value, format = 'HH:mm:ss') {
  11. let duration = Number(value || 0);
  12. return timeUnits.reduce((current, [name, unit]) => {
  13. if (current.indexOf(name) !== -1) {
  14. const v = Math.floor(duration / unit);
  15. duration -= v * unit;
  16. return current.replace(new RegExp(`${name}+`, 'g'), (match) => padStart(v.toString(), match.length, '0'));
  17. }
  18. return current;
  19. }, format);
  20. }
  21. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzTimeRangePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
  22. static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzTimeRangePipe, isStandalone: true, name: "nzTimeRange" });
  23. }
  24. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzTimeRangePipe, decorators: [{
  25. type: Pipe,
  26. args: [{
  27. name: 'nzTimeRange',
  28. pure: true
  29. }]
  30. }] });
  31. /**
  32. * Use of this source code is governed by an MIT-style license that can be
  33. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  34. */
  35. class NzPipesModule {
  36. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  37. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzPipesModule, imports: [NzTimeRangePipe], exports: [NzTimeRangePipe] });
  38. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzPipesModule });
  39. }
  40. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzPipesModule, decorators: [{
  41. type: NgModule,
  42. args: [{
  43. imports: [NzTimeRangePipe],
  44. exports: [NzTimeRangePipe]
  45. }]
  46. }] });
  47. /**
  48. * Use of this source code is governed by an MIT-style license that can be
  49. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  50. */
  51. /**
  52. * Generated bundle index. Do not edit.
  53. */
  54. export { NzPipesModule, NzTimeRangePipe };
  55. //# sourceMappingURL=ng-zorro-antd-core-pipe.mjs.map