Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v14.4.1 (2023-02-15)
* **dateformat** use luxon for absolute time if enabled

# v14.4.0 (2023-02-13)
* **dateformat** fixes default luxon formatting

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-components",
"version": "14.4.0",
"version": "14.4.1",
"author": {
"name": "UiPath Inc",
"url": "https://uipath.com"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'moment-timezone';

import {
DateTime,
DateTimeFormatOptions,
DateTime,
DateTimeFormatOptions,
} from 'luxon';
import moment from 'moment';
import {
Expand Down Expand Up @@ -205,15 +205,15 @@ export class UiDateFormatDirective extends UiFormatDirective {
if (!this.date) { return ''; }
if (!(this.date instanceof Date)) { return this.date; }

const absoluteTime = this._isMomentFormat(this.dateFormat)
? moment(this.date)
let absoluteTime;

if (this._useLuxon) {
absoluteTime = this._luxonAbsoluteTime(this.date);
} else if (this._isStringFormat(this.dateFormat)) {
absoluteTime = moment(this.date)
.tz(this.timezone ?? resolveTimezone(this._options))
.format(this.dateFormat)
: DateTime
.fromJSDate(this.date, {
zone: this.timezone ?? resolveTimezone(this._options),
})
.toLocaleString(this.dateFormat);
.format(this.dateFormat);
}

return absoluteTime ?? '';
}
Expand Down Expand Up @@ -304,7 +304,7 @@ export class UiDateFormatDirective extends UiFormatDirective {
this._renderer.setAttribute(this._elementRef.nativeElement, 'data-title', this._timeForType(this.titleType));
}

private _isMomentFormat(format: string | DateTimeFormatOptions): format is string {
private _isStringFormat(format: string | DateTimeFormatOptions): format is string {
return typeof format === 'string';
}

Expand All @@ -326,4 +326,15 @@ export class UiDateFormatDirective extends UiFormatDirective {

return value !== compareValue;
};

private _luxonAbsoluteTime(date: Date) {
const time = DateTime
.fromJSDate(date, {
zone: this.timezone ?? resolveTimezone(this._options),
});

return this._isStringFormat(this.dateFormat)
? time.toFormat(this.dateFormat)
: time.toLocaleString(this.dateFormat);
}
}
2 changes: 1 addition & 1 deletion projects/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uipath/angular",
"version": "14.4.0",
"version": "14.4.1",
"license": "MIT",
"author": {
"name": "UiPath Inc",
Expand Down