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

IgniteUI / igniteui-angular / 13113215929

03 Feb 2025 12:13PM CUT coverage: 91.602% (-0.02%) from 91.623%
13113215929

Pull #15311

github

web-flow
Merge a1742e7c4 into acda41b60
Pull Request #15311: fix(icon-button): remove z-index to material outlined button

12990 of 15230 branches covered (85.29%)

26341 of 28756 relevant lines covered (91.6%)

34025.65 hits per line

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

87.27
/projects/igniteui-angular/src/lib/calendar/calendar.ts
1
import { mkenum } from '../core/utils';
2

3
/**
4
 * Sets the selection type - single, multi or range.
5
 */
6
export const CalendarSelection = /*@__PURE__*/mkenum({
2✔
7
    SINGLE: 'single',
8
    MULTI: 'multi',
9
    RANGE: 'range'
10
});
11
export type CalendarSelection = (typeof CalendarSelection)[keyof typeof CalendarSelection];
12

13
export const enum ScrollDirection {
14
    PREV = 'prev',
15
    NEXT = 'next',
16
    NONE = 'none'
17
}
18

19
export interface IViewDateChangeEventArgs {
20
    previousValue: Date;
21
    currentValue: Date;
22
}
23

24
export const IgxCalendarView = /*@__PURE__*/mkenum({
2✔
25
    Month: 'month',
26
    Year: 'year',
27
    Decade: 'decade'
28
});
29

30
/**
31
 * Determines the Calendar active view - days, months or years.
32
 */
33
export type IgxCalendarView = (typeof IgxCalendarView)[keyof typeof IgxCalendarView];
34

35
const MDAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2✔
36
const FEBRUARY = 1;
2✔
37

38
export const range = (start = 0, stop: number, step = 1) => {
2!
39
    const res = [];
×
40
    const cur = (stop === undefined) ? 0 : start;
×
41
    const max = (stop === undefined) ? start : stop;
×
42
    for (let i = cur; step < 0 ? i > max : i < max; i += step) {
×
43
        res.push(i);
×
44
    }
45
    return res;
×
46
};
47

48
/**
49
 * Returns true for leap years, false for non-leap years.
50
 *
51
 * @export
52
 * @param year
53
 * @returns
54
 */
55
export const isLeap = (year: number): boolean => (year % 4 === 0) && ((year % 100 !== 0) || (year % 400 === 0));
3!
56

57
export const weekDay = (year: number, month: number, day: number): number => new Date(year, month, day).getDay();
4✔
58

59
/**
60
 * Return weekday and number of days for year, month.
61
 *
62
 * @export
63
 * @param year
64
 * @param month
65
 * @returns
66
 */
67
export const monthRange = (year: number, month: number): number[] => {
2✔
68
    if ((month < 0) || (month > 11)) {
4✔
69
        throw new Error('Invalid month specified');
2✔
70
    }
71
    const day = weekDay(year, month, 1);
2✔
72
    let nDays = MDAYS[month];
2✔
73
    if ((month === FEBRUARY) && (isLeap(year))) {
2✔
74
        nDays++;
1✔
75
    }
76
    return [day, nDays];
2✔
77
};
78

79
export interface IFormattedParts {
80
    value: string;
81
    literal?: string;
82
    combined: string;
83
}
84

85
export interface IFormattingOptions {
86
    day?: 'numeric' | '2-digit';
87
    month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
88
    weekday?: 'long' | 'short' | 'narrow';
89
    year?: 'numeric' | '2-digit';
90
}
91

92
export interface IFormattingViews {
93
    day?: boolean;
94
    month?: boolean;
95
    year?: boolean;
96
}
97

98
export enum WEEKDAYS {
2✔
99
    SUNDAY,
2✔
100
    MONDAY,
2✔
101
    TUESDAY,
2✔
102
    WEDNESDAY,
2✔
103
    THURSDAY,
2✔
104
    FRIDAY,
2✔
105
    SATURDAY
2✔
106
}
107

108
export class Calendar {
109
    public timedelta(date: Date, interval: string, units: number): Date {
110
        const ret = new Date(date);
8,427✔
111

112
        const checkRollover = () => {
8,427✔
113
            if (ret.getDate() !== date.getDate()) {
3,244!
114
                ret.setDate(0);
×
115
            }
116
        };
117

118
        switch (interval.toLowerCase()) {
8,427✔
119
            case 'year':
120
                ret.setFullYear(ret.getFullYear() + units);
2✔
121
                checkRollover();
2✔
122
                break;
2✔
123
            case 'quarter':
124
                ret.setMonth(ret.getMonth() + 3 * units);
2✔
125
                checkRollover();
2✔
126
                break;
2✔
127
            case 'month':
128
                ret.setMonth(ret.getMonth() + units);
3,240✔
129
                checkRollover();
3,240✔
130
                break;
3,240✔
131
            case 'week':
132
                ret.setDate(ret.getDate() + 7 * units);
3✔
133
                break;
3✔
134
            case 'day':
135
                ret.setDate(ret.getDate() + units);
1,343✔
136
                break;
1,343✔
137
            case 'hour':
138
                ret.setTime(ret.getTime() + units * 3600000);
1,536✔
139
                break;
1,536✔
140
            case 'minute':
141
                ret.setTime(ret.getTime() + units * 60000);
1,531✔
142
                break;
1,531✔
143
            case 'second':
144
                ret.setTime(ret.getTime() + units * 1000);
769✔
145
                break;
769✔
146
            default:
147
                throw new Error('Invalid interval specifier');
1✔
148
        }
149

150
        return ret;
8,426✔
151
    }
152
}
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