@energycap/components 0.32.12 → 0.32.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/shared/display/pipes/relative-date.pipe.mjs +18 -4
- package/fesm2015/energycap-components.mjs +18 -3
- package/fesm2015/energycap-components.mjs.map +1 -1
- package/fesm2020/energycap-components.mjs +17 -3
- package/fesm2020/energycap-components.mjs.map +1 -1
- package/lib/shared/display/pipes/relative-date.pipe.d.ts +12 -2
- package/package.json +1 -1
|
@@ -7981,9 +7981,11 @@ class RelativeDatePipe {
|
|
|
7981
7981
|
}
|
|
7982
7982
|
/**
|
|
7983
7983
|
* If dateOnly is true, returns timeSelected formatted according to the user's date preference.
|
|
7984
|
-
* If
|
|
7984
|
+
* If dateOnly is true and showTimeForToday is false and timeSelected is today, returns 'today' or todayLabel
|
|
7985
|
+
* If dateOnly and showTimeForToday is true and timeSelected is today, returns timeSelected formatted according to the user's time preference.
|
|
7986
|
+
* If dateOnly is false, returns timeSelected formatted according to the user's time preference.
|
|
7987
|
+
* If dateOnly is false and timeSelected is not today/yesterday, returns timeSelected formatted according to the user's date plus time preference.
|
|
7985
7988
|
* If any of todayLabel, yesterdayLabel is supplied, use the supplied label.
|
|
7986
|
-
* If dateOnly and timeOnly are both false, returns timeSelected formatted according to the user's date plus time preference.
|
|
7987
7989
|
*/
|
|
7988
7990
|
transform(timeSelected, options) {
|
|
7989
7991
|
const selected = moment(timeSelected);
|
|
@@ -7991,19 +7993,31 @@ class RelativeDatePipe {
|
|
|
7991
7993
|
const yesterday = moment().subtract(1, 'day');
|
|
7992
7994
|
const timeDisplay = options?.dateOnly ? `` : ` ${this.timeDisplayPipe.transform(timeSelected)}`;
|
|
7993
7995
|
let displayValue = null;
|
|
7996
|
+
let prefixValue = '';
|
|
7994
7997
|
if (selected.isSame(today, 'day') && !options?.showTimeForToday) {
|
|
7995
7998
|
displayValue = this.translateService.instant(options?.todayLabel ? options?.todayLabel : 'today');
|
|
7999
|
+
prefixValue = options?.todayPrefix ?? '';
|
|
7996
8000
|
}
|
|
7997
8001
|
else if (selected.isSame(today, 'day') && options?.showTimeForToday && !timeDisplay) {
|
|
7998
8002
|
displayValue = this.timeDisplayPipe.transform(timeSelected);
|
|
8003
|
+
prefixValue = options?.todayTimePrefix ?? '';
|
|
7999
8004
|
}
|
|
8000
8005
|
else if (selected.isSame(yesterday, 'day')) {
|
|
8001
8006
|
displayValue = this.translateService.instant(options?.yesterdayLabel ? options?.yesterdayLabel : 'yesterday');
|
|
8007
|
+
prefixValue = options?.yesterdayPrefix ?? '';
|
|
8002
8008
|
}
|
|
8003
8009
|
else {
|
|
8004
8010
|
displayValue = this.dateDisplayPipe.transform(timeSelected);
|
|
8005
8011
|
}
|
|
8006
|
-
|
|
8012
|
+
// If we have a default prefix and no specific ones were set earlier apply the default prefix
|
|
8013
|
+
if (options?.defaultPrefix && prefixValue === '') {
|
|
8014
|
+
prefixValue = options.defaultPrefix;
|
|
8015
|
+
}
|
|
8016
|
+
// Add a space after our prefix if defined
|
|
8017
|
+
if (prefixValue !== '') {
|
|
8018
|
+
prefixValue = `${prefixValue} `;
|
|
8019
|
+
}
|
|
8020
|
+
return `${prefixValue}${displayValue}${timeDisplay}`;
|
|
8007
8021
|
}
|
|
8008
8022
|
}
|
|
8009
8023
|
RelativeDatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: RelativeDatePipe, deps: [{ token: DateDisplayPipe }, { token: TimeDisplayPipe }, { token: i2.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
|