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

atinc / ngx-tethys / 269bc1f1-a472-43fb-93e2-518e47073c10

24 Mar 2025 09:10AM UTC coverage: 90.187% (-0.04%) from 90.223%
269bc1f1-a472-43fb-93e2-518e47073c10

Pull #3313

circleci

xinglu01
feat(date-picker): support date-fns i18n and support thySeparator
Pull Request #3313: feat(date-picker): support date-fns i18n and support thySeparator

5586 of 6858 branches covered (81.45%)

Branch coverage included in aggregate %.

22 of 28 new or added lines in 7 files covered. (78.57%)

37 existing lines in 6 files now uncovered.

13347 of 14135 relevant lines covered (94.43%)

992.21 hits per line

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

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

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

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

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

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

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

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

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

71
/**
1✔
72
 * @private
73
 */
74
@Pipe({
75
    name: 'thyDatePickerFormatString',
76
    standalone: true
77
})
78
export class ThyDatePickerFormatStringPipe implements PipeTransform {
79
    private dateHelper = inject(DateHelperService);
80

81
    transform(originalValue: CompatibleDate | DateEntry | ThyDateRangeEntry): string {
82
        const { withTime } = transformDateValue(originalValue);
1✔
83

UNCOV
84
        return withTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd';
×
85
    }
86
}
UNCOV
87

×
UNCOV
88
/**
×
89
 * @private
90
 */
91
@Pipe({
1✔
92
    name: 'showYearTip',
93
    standalone: true
94
})
95
export class DatePickerAdvancedShowYearTipPipe implements PipeTransform {
96
    constructor() {}
97
    transform(value: AdvancedSelectableCell, type: ThyDateGranularity): boolean {
98
        return type !== 'year' && value.startValue.isSameDay(value.startValue.startOfYear());
99
    }
100
}
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