< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 42
Coverable lines: 42
Total lines: 165
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%110%
.ctor()100%110%
AddMonths(...)100%110%
AddYears(...)100%110%
GetDaysInMonth(...)100%110%
GetDaysInYear(...)100%110%
GetDayOfMonth(...)100%110%
GetDayOfWeek(...)100%110%
GetDayOfYear(...)100%110%
GetMonthsInYear(...)100%110%
GetWeekOfYear(...)100%110%
GetEra(...)100%110%
GetMonth(...)100%110%
GetYear(...)100%110%
IsLeapDay(...)100%110%
IsLeapYear(...)100%110%
GetLeapMonth(...)100%110%
IsLeapMonth(...)100%110%
ToDateTime(...)100%110%
ToFourDigitYear(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/Globalization/ThaiBuddhistCalendar.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4namespace System.Globalization
 5{
 6    /// <summary>
 7    /// ThaiBuddhistCalendar is based on Gregorian calendar.
 8    /// Its year value has an offset to the Gregorain calendar.
 9    /// </summary>
 10    /// <remarks>
 11    /// Calendar support range:
 12    ///     Calendar    Minimum     Maximum
 13    ///     ==========  ==========  ==========
 14    ///     Gregorian   0001/01/01   9999/12/31
 15    ///     Thai        0544/01/01  10542/12/31
 16    /// </remarks>
 17    public class ThaiBuddhistCalendar : Calendar
 18    {
 019        private static readonly EraInfo[] s_thaiBuddhistEraInfo =
 020        [
 021            new EraInfo(1, 1, 1, 1, -543, 544, GregorianCalendar.MaxYear + 543)     // era #, start year/month/day, year
 022        ];
 23
 24        public const int ThaiBuddhistEra = 1;
 25
 26        private readonly GregorianCalendarHelper _helper;
 27
 028        public override DateTime MinSupportedDateTime => DateTime.MinValue;
 29
 030        public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
 31
 032        public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
 33
 034        public ThaiBuddhistCalendar()
 35        {
 036            _helper = new GregorianCalendarHelper(this, s_thaiBuddhistEraInfo);
 037        }
 38
 039        internal override CalendarId ID => CalendarId.THAI;
 40
 41        public override DateTime AddMonths(DateTime time, int months)
 42        {
 043            return _helper.AddMonths(time, months);
 44        }
 45
 46        public override DateTime AddYears(DateTime time, int years)
 47        {
 048            return _helper.AddYears(time, years);
 49        }
 50
 51        public override int GetDaysInMonth(int year, int month, int era)
 52        {
 053            return _helper.GetDaysInMonth(year, month, era);
 54        }
 55
 56        public override int GetDaysInYear(int year, int era)
 57        {
 058            return _helper.GetDaysInYear(year, era);
 59        }
 60
 61        public override int GetDayOfMonth(DateTime time)
 62        {
 063            return _helper.GetDayOfMonth(time);
 64        }
 65
 66        public override DayOfWeek GetDayOfWeek(DateTime time)
 67        {
 068            return _helper.GetDayOfWeek(time);
 69        }
 70
 71        public override int GetDayOfYear(DateTime time)
 72        {
 073            return _helper.GetDayOfYear(time);
 74        }
 75
 76        public override int GetMonthsInYear(int year, int era)
 77        {
 078            return _helper.GetMonthsInYear(year, era);
 79        }
 80
 81        public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
 82        {
 083            return _helper.GetWeekOfYear(time, rule, firstDayOfWeek);
 84        }
 85
 86        public override int GetEra(DateTime time)
 87        {
 088            return _helper.GetEra(time);
 89        }
 90
 91        public override int GetMonth(DateTime time)
 92        {
 093            return _helper.GetMonth(time);
 94        }
 95
 96        public override int GetYear(DateTime time)
 97        {
 098            return _helper.GetYear(time);
 99        }
 100
 101        public override bool IsLeapDay(int year, int month, int day, int era)
 102        {
 0103            return _helper.IsLeapDay(year, month, day, era);
 104        }
 105
 106        public override bool IsLeapYear(int year, int era)
 107        {
 0108            return _helper.IsLeapYear(year, era);
 109        }
 110
 111        public override int GetLeapMonth(int year, int era)
 112        {
 0113            return _helper.GetLeapMonth(year, era);
 114        }
 115
 116        public override bool IsLeapMonth(int year, int month, int era)
 117        {
 0118            return _helper.IsLeapMonth(year, month, era);
 119        }
 120
 121        public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisec
 122        {
 0123            return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era);
 124        }
 125
 0126        public override int[] Eras => _helper.Eras;
 127
 128        private const int DefaultTwoDigitYearMax = 2572;
 129
 130
 131        public override int TwoDigitYearMax
 132        {
 133            get
 134            {
 0135                if (_twoDigitYearMax == -1)
 136                {
 0137                    _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
 138                }
 139
 0140                return _twoDigitYearMax;
 141            }
 142            set
 143            {
 0144                VerifyWritable();
 0145                if (value < 99 || value > _helper.MaxYear)
 146                {
 0147                    throw new ArgumentOutOfRangeException(
 0148                        nameof(value),
 0149                        value,
 0150                        SR.Format(SR.ArgumentOutOfRange_Range, 99, _helper.MaxYear));
 151                }
 152
 0153                _twoDigitYearMax = value;
 0154            }
 155        }
 156
 157        public override int ToFourDigitYear(int year)
 158        {
 0159            ArgumentOutOfRangeException.ThrowIfNegative(year);
 160
 0161            return _helper.ToFourDigitYear(year, TwoDigitYearMax);
 162        }
 163    }
 164}
 165