@lxlib/theme
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
51 lines • 4.16 kB
JavaScript
/**
* @fileoverview added by tsickle
* Generated from: src/pipes/date/date.pipe.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { Pipe } from '@angular/core';
import format from 'date-fns/format';
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
import parse from 'date-fns/parse';
import { NzI18nService } from 'ng-zorro-antd/i18n';
var DatePipe = /** @class */ (function () {
function DatePipe(nzI18n) {
this.nzI18n = nzI18n;
}
/**
* @param {?} value
* @param {?=} formatString
* @return {?}
*/
DatePipe.prototype.transform = /**
* @param {?} value
* @param {?=} formatString
* @return {?}
*/
function (value, formatString) {
if (formatString === void 0) { formatString = 'yyyy-MM-dd HH:mm'; }
/** @type {?} */
var options = { locale: this.nzI18n.getDateLocale() };
value = typeof value === 'string' ? (!isNaN(+value) ? +value : parse(value, formatString, new Date(), options)) : value;
if (!value)
return '';
return formatString === 'fn' ? formatDistanceToNow(value, options) : format(value, formatString, options);
};
DatePipe.decorators = [
{ type: Pipe, args: [{ name: '_date' },] }
];
/** @nocollapse */
DatePipe.ctorParameters = function () { return [
{ type: NzI18nService }
]; };
return DatePipe;
}());
export { DatePipe };
if (false) {
/**
* @type {?}
* @private
*/
DatePipe.prototype.nzI18n;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZS5waXBlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGx4bGliL3RoZW1lLyIsInNvdXJjZXMiOlsic3JjL3BpcGVzL2RhdGUvZGF0ZS5waXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsT0FBTyxFQUFFLElBQUksRUFBaUIsTUFBTSxlQUFlLENBQUM7QUFDcEQsT0FBTyxNQUFNLE1BQU0saUJBQWlCLENBQUM7QUFDckMs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