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

atinc / ngx-tethys / 10698a89-6a67-4df9-92de-a09375e9923d

12 Dec 2023 02:44AM UTC coverage: 90.216% (-0.2%) from 90.396%
10698a89-6a67-4df9-92de-a09375e9923d

Pull #2967

circleci

mengshuicmq
Merge branch 'cmq/feat-#INFR-10719' of https://github.com/atinc/ngx-tethys into cmq/feat-#INFR-10719
Pull Request #2967: feat(datePicker): date-picker support quarter(#INFR-10719)

5366 of 6616 branches covered (0.0%)

Branch coverage included in aggregate %.

60 of 83 new or added lines in 7 files covered. (72.29%)

19 existing lines in 5 files now uncovered.

13390 of 14174 relevant lines covered (94.47%)

968.26 hits per line

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

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

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

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

21
        if (!formatStr) {
22
            formatStr = withTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd';
×
23
        }
×
24

×
25
        if (!Array.isArray(value)) {
26
            return this.dateHelper.format(value, formatStr);
27
        } else {
×
28
            if (flexibleDateGranularity && flexibleDateGranularity !== 'day') {
29
                const tinyDates = [new TinyDate(value[0]), new TinyDate(value[1])];
30
                return getFlexibleAdvancedReadableValue(tinyDates, flexibleDateGranularity);
31
            } else {
1✔
32
                return value.map(date => this.dateHelper.format(date, formatStr)).join(' ~ ');
33
            }
34
        }
35
    }
1✔
36
}
37

38
@Pipe({
39
    name: 'thyQuarterPickerFormat',
40
    standalone: true
41
})
42
export class ThyQuarterPickerFormatPipe implements PipeTransform {
43
    transform(originalValue: CompatibleDate | DateEntry | ThyDateRangeEntry, formatStr?: string): string {
1✔
44
        const { value, withTime } = transformDateValue(originalValue);
NEW
45

×
NEW
46
        if (!formatStr) {
×
NEW
47
            formatStr = 'yyyy-qqq';
×
48
        }
NEW
49

×
NEW
50
        if (!value) {
×
51
            return;
NEW
52
        }
×
NEW
53

×
NEW
54
        if (!Array.isArray(value)) {
×
55
            const _value = new TinyDate(value);
56
            return _value.format(formatStr);
NEW
57
        } else {
×
58
            return value
NEW
59
                .map(date => {
×
NEW
60
                    const _date = new TinyDate(date);
×
61
                    return _date.format(formatStr);
62
                })
63
                .join(' ~ ');
64
        }
65
    }
66
}
1✔
67

68
/**
69
 * @private
70
 */
71
@Pipe({
72
    name: 'thyDatePickerFormatString',
73
    standalone: true
74
})
75
export class ThyDatePickerFormatStringPipe implements PipeTransform {
76
    constructor(private dateHelper: DateHelperService) {}
1✔
77

78
    transform(originalValue: CompatibleDate | DateEntry | ThyDateRangeEntry): string {
×
79
        const { withTime } = transformDateValue(originalValue);
80

81
        return withTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd';
×
82
    }
×
83
}
84

1✔
85
/**
86
 * @private
87
 */
88
@Pipe({
1✔
89
    name: 'showYearTip',
90
    standalone: true
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
}
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