ngx-cf-date-time-label
Version:
<img src="https://www.codzfun.com/assets/images/logo-icon.png" width="50" height="auto" alt="ng-textarea-enter icon"/>
66 lines (60 loc) • 1.97 kB
JavaScript
import { __decorate } from 'tslib';
import { Input, Component, NgModule } from '@angular/core';
import { tz, utc } from 'moment-timezone';
let NgxCfDateTimeLabelComponent = class NgxCfDateTimeLabelComponent {
constructor() {
this.format = 'YYYY-MM-DD HH:mm:ss';
this.val = "";
this.timeZone = "";
this.formattedValue = this.val;
}
ngOnInit() {
}
getFormatedValue() {
let isoString;
if (typeof this.val == 'string') {
isoString = this.val;
}
else if (typeof this.val == 'object' && typeof this.val["toISOString"] == 'function') {
isoString = this.val.toISOString();
}
if (this.timeZone == "" && typeof tz == 'function') {
this.timeZone = tz.guess();
}
return this.timeZone && this.timeZone != "" ? utc(isoString).tz(this.timeZone).format(this.format) : utc(isoString).format(this.format);
}
};
__decorate([
Input()
], NgxCfDateTimeLabelComponent.prototype, "format", void 0);
__decorate([
Input('value')
], NgxCfDateTimeLabelComponent.prototype, "val", void 0);
__decorate([
Input()
], NgxCfDateTimeLabelComponent.prototype, "timeZone", void 0);
NgxCfDateTimeLabelComponent = __decorate([
Component({
selector: 'NgxCF-DateTimeLabel',
template: `
<label>{{getFormatedValue()}}</label>
`
})
], NgxCfDateTimeLabelComponent);
let NgxCfDateTimeLabelModule = class NgxCfDateTimeLabelModule {
};
NgxCfDateTimeLabelModule = __decorate([
NgModule({
declarations: [NgxCfDateTimeLabelComponent],
imports: [],
exports: [NgxCfDateTimeLabelComponent]
})
], NgxCfDateTimeLabelModule);
/*
* Public API Surface of ngx-cf-date-time-label
*/
/**
* Generated bundle index. Do not edit.
*/
export { NgxCfDateTimeLabelComponent, NgxCfDateTimeLabelModule };
//# sourceMappingURL=ngx-cf-date-time-label.js.map