• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / #86

11 Aug 2025 06:20AM UTC coverage: 90.315% (+0.01%) from 90.302%
#86

push

web-flow
Merge 934a56b76 into 6d22be5bb

5532 of 6819 branches covered (81.13%)

Branch coverage included in aggregate %.

351 of 379 new or added lines in 20 files covered. (92.61%)

62 existing lines in 12 files now uncovered.

13957 of 14760 relevant lines covered (94.56%)

904.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.58
/src/date-picker/picker.pipes.ts
1
import { Pipe, PipeTransform, inject } from '@angular/core';
2
import { ThyI18nService } from 'ngx-tethys/i18n';
3
import { TinyDate } from 'ngx-tethys/util';
4
import { DateHelperService } from './date-helper.service';
5
import { ThyDatePickerConfigService } from './date-picker.service';
6
import { AdvancedSelectableCell } from './inner-types';
7
import { getFlexibleAdvancedReadableValue, transformDateValue } from './picker.util';
8
import { ThyCompatibleDate, DateEntry, ThyDateGranularity, ThyDateRangeEntry } from './standard-types';
9

10
/**
11
 * @private
1✔
12
 */
13
@Pipe({
28✔
14
    name: 'thyDatePickerFormat'
28✔
15
})
28✔
16
export class ThyDatePickerFormatPipe implements PipeTransform {
17
    private dateHelper = inject(DateHelperService);
18
    private datePickerConfigService = inject(ThyDatePickerConfigService);
55✔
19
    private i18n = inject(ThyI18nService);
55✔
20

46!
21
    transform(originalValue: ThyCompatibleDate | DateEntry | ThyDateRangeEntry, formatStr?: string, separator?: string): string {
22
        const { value, withTime, flexibleDateGranularity } = transformDateValue(originalValue);
55✔
23

55!
24
        if (!formatStr) {
55✔
25
            formatStr = withTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd';
26
        }
27
        const currentSeparator = ` ${(separator ?? this.datePickerConfigService.separator)?.trim()} `;
×
28
        if (!Array.isArray(value)) {
×
29
            return this.dateHelper.format(value, formatStr);
×
30
        } else {
31
            if (flexibleDateGranularity && flexibleDateGranularity !== 'day') {
32
                const tinyDates = [new TinyDate(value[0]), new TinyDate(value[1])];
×
33
                return getFlexibleAdvancedReadableValue(tinyDates, flexibleDateGranularity, currentSeparator, this.i18n.getLocale());
34
            } else {
35
                return value.map(date => this.dateHelper.format(date, formatStr)).join(currentSeparator);
36
            }
37
        }
1✔
38
    }
39
}
40

41
@Pipe({
42
    name: 'thyQuarterPickerFormat'
43
})
1✔
44
export class ThyQuarterPickerFormatPipe implements PipeTransform {
45
    constructor(private datePickerConfigService: ThyDatePickerConfigService) {}
2✔
46

47
    transform(originalValue: ThyCompatibleDate | DateEntry | ThyDateRangeEntry, formatStr?: string, separator?: string): string {
48
        const { value, withTime } = transformDateValue(originalValue);
2✔
49

2!
50
        if (!formatStr) {
2✔
51
            formatStr = 'yyyy-qqq';
52
        }
2!
53

×
54
        if (!value) {
55
            return;
2✔
56
        }
1✔
57

1✔
58
        if (!Array.isArray(value)) {
59
            const _value = new TinyDate(value);
60
            return _value.format(formatStr);
1✔
61
        } else {
62
            return value
2✔
63
                .map(date => {
2✔
64
                    const _date = new TinyDate(date);
65
                    return _date.format(formatStr);
2✔
66
                })
67
                .join(` ${(separator ?? this.datePickerConfigService.separator)?.trim()} `);
68
        }
1✔
69
    }
70
}
71

72
/**
1✔
73
 * @private
74
 */
75
@Pipe({
76
    name: 'thyDatePickerFormatString'
77
})
78
export class ThyDatePickerFormatStringPipe implements PipeTransform {
79
    transform(originalValue: ThyCompatibleDate | DateEntry | ThyDateRangeEntry): string {
80
        const { withTime } = transformDateValue(originalValue);
81

82
        return withTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd';
1✔
83
    }
UNCOV
84
}
×
85

×
86
/**
87
 * @private
88
 */
1✔
89
@Pipe({
90
    name: 'showYearTip'
91
})
92
export class DatePickerAdvancedShowYearTipPipe implements PipeTransform {
93
    constructor() {}
94
    transform(value: AdvancedSelectableCell, type: ThyDateGranularity): boolean {
95
        return type !== 'year' && value.startValue.isSameDay(value.startValue.startOfYear());
96
    }
97
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc