@@ -587,8 +587,8 @@ public DateTime SubtractYears(int years) =>
587587
588588 /// <summary>Format a compact date (removes empty time parts)</summary>
589589 /// <returns>The formatted period start date</returns>
590- public string ToCompactString ( ) => moment . IsMidnight ( ) ?
591- moment . ToShortDateString ( ) :
590+ public string ToCompactString ( ) => moment . IsMidnight ( ) ?
591+ moment . ToShortDateString ( ) :
592592 $ "{ moment . ToShortDateString ( ) } { moment . ToShortTimeString ( ) } ";
593593
594594 /// <summary>Format a period start date (removes empty time parts), using the current culture</summary>
@@ -597,8 +597,8 @@ public string ToCompactString() => moment.IsMidnight() ?
597597
598598 /// <summary>Format a period end date (removed empty time parts, and round last moment values), using the current culture</summary>
599599 /// <returns>The formatted period end date</returns>
600- public string ToPeriodEndString ( ) => moment . IsMidnight ( ) || moment . IsLastMomentOfDay ( ) ?
601- moment . ToShortDateString ( ) :
600+ public string ToPeriodEndString ( ) => moment . IsMidnight ( ) || moment . IsLastMomentOfDay ( ) ?
601+ moment . ToShortDateString ( ) :
602602 $ "{ moment . ToShortDateString ( ) } { moment . ToShortTimeString ( ) } ";
603603
604604 /// <summary>Test if the date is in UTC</summary>
@@ -775,7 +775,7 @@ public bool IsFirstDayOfMonth(Month month) =>
775775 /// <summary>Test if a specific day is the last day of the month</summary>
776776 /// <param name="ignoreLeapYear">Ignore the leap year day</param>
777777 /// <returns>True if the test day is the last day of the month</returns>
778- public bool IsLastDayOfMonth ( bool ignoreLeapYear = false ) =>
778+ public bool IsLastDayOfMonth ( bool ignoreLeapYear = false ) =>
779779 moment . IsLastDayOfMonth ( moment . Month ( ) , ignoreLeapYear ) ;
780780
781781 /// <summary>Test if a specific day is the last day of the month</summary>
@@ -1152,8 +1152,15 @@ public object GetValue(string key, object defaultValue = null)
11521152 /// <param name="key">The value key</param>
11531153 /// <param name="defaultValue">The default value</param>
11541154 /// <returns>The dictionary value</returns>
1155- public T GetValue < T > ( string key , T defaultValue = default ) =>
1156- ( T ) Convert . ChangeType ( dictionary . GetValue ( key , ( object ) defaultValue ) , typeof ( T ) ) ;
1155+ public T GetValue < T > ( string key , T defaultValue = default )
1156+ {
1157+ var value = dictionary . GetValue ( key ) ;
1158+ if ( value == null )
1159+ {
1160+ return defaultValue ;
1161+ }
1162+ return ( T ) value ;
1163+ }
11571164 }
11581165
11591166 /// <summary>Get value from a string/JSON-string dictionary</summary>
@@ -1319,7 +1326,7 @@ public List<DatePeriod> Split(List<DateTime> splitMoments)
13191326 splitPeriods . Add ( new ( last . End . NextTick ( ) , period . End ) ) ;
13201327 }
13211328 }
1322- return splitPeriods ;
1329+ return splitPeriods . Any ( ) ? splitPeriods : [ period ] ;
13231330 }
13241331
13251332 /// <summary>Get period days</summary>
@@ -1460,10 +1467,11 @@ public TimeSpan TotalDuration()
14601467
14611468 /// <summary>Test if any period is overlapping another period</summary>
14621469 /// <returns>True, if the period is overlapping this period</returns>
1470+ /// <remarks>Fixed: outer loop starts at 0 to include the first element in comparisons.</remarks>
14631471 public bool HasOverlapping ( )
14641472 {
14651473 var periodList = datePeriods . ToList ( ) ;
1466- for ( var current = 1 ; current < periodList . Count ; current ++ )
1474+ for ( var current = 0 ; current < periodList . Count ; current ++ )
14671475 {
14681476 for ( var remain = current + 1 ; remain < periodList . Count ; remain ++ )
14691477 {
@@ -1568,7 +1576,7 @@ public bool IsWithin(decimal test) =>
15681576 /// <summary>Test if a specific time period is within the period, including open periods</summary>
15691577 /// <param name="testPeriod">The period to test</param>
15701578 /// <returns>True, if the test period is within this period</returns>
1571- public bool IsWithin ( HourPeriod testPeriod ) =>
1579+ public bool IsWithin ( HourPeriod testPeriod ) =>
15721580 period . IsWithin ( testPeriod . Start ) && period . IsWithin ( testPeriod . End ) ;
15731581
15741582 /// <summary>Test if a specific time moment is within or before the period, including open periods</summary>
@@ -1626,10 +1634,11 @@ public TimeSpan TotalDuration()
16261634
16271635 /// <summary>Test if any period is overlapping another period</summary>
16281636 /// <returns>True, if the period is overlapping this period</returns>
1637+ /// <remarks>Fixed: outer loop starts at 0 to include the first element in comparisons.</remarks>
16291638 public bool HasOverlapping ( )
16301639 {
16311640 var periodList = timePeriods . ToList ( ) ;
1632- for ( var current = 1 ; current < periodList . Count ; current ++ )
1641+ for ( var current = 0 ; current < periodList . Count ; current ++ )
16331642 {
16341643 for ( var remain = current + 1 ; remain < periodList . Count ; remain ++ )
16351644 {
@@ -2203,7 +2212,7 @@ valueType is ValueType.Date or
22032212
22042213 /// <summary>Test if value type is a number</summary>
22052214 /// <returns>True for number value types</returns>
2206- public bool IsNumber ( ) =>
2215+ public bool IsNumber ( ) =>
22072216 valueType . IsInteger ( ) || valueType . IsDecimal ( ) ;
22082217
22092218 /// <summary>Test if value type is an integer</summary>
@@ -2376,7 +2385,7 @@ public static CaseValue TupleToCaseValue(this Tuple<string, DateTime, Tuple<Date
23762385 /// <summary>Convert tuple values to case values</summary>
23772386 /// <param name="values">The tuple values</param>
23782387 /// <returns>The case period values</returns>
2379- public static List < CaseValue > TupleToCaseValues ( this List < Tuple < string , DateTime ,
2388+ public static List < CaseValue > TupleToCaseValues ( this List < Tuple < string , DateTime ,
23802389 Tuple < DateTime ? , DateTime ? > , object , DateTime ? , List < string > , Dictionary < string , object > > > values )
23812390 {
23822391 var caseValues = new List < CaseValue > ( ) ;
@@ -2386,7 +2395,7 @@ public static List<CaseValue> TupleToCaseValues(this List<Tuple<string, DateTime
23862395 {
23872396 if ( value != null )
23882397 {
2389- caseValues . Add ( new ( value . Item1 , value . Item2 , value . Item3 . Item1 ,
2398+ caseValues . Add ( new ( value . Item1 , value . Item2 , value . Item3 . Item1 ,
23902399 value . Item3 . Item2 , new ( value . Item4 ) , value . Item5 , value . Item6 , value . Item7 ) ) ;
23912400 }
23922401 }
@@ -2401,19 +2410,23 @@ public static CasePayrollValueDictionary TupleToCaseValuesDictionary(this Dictio
24012410 List < Tuple < DateTime , DateTime ? , DateTime ? , object > > > values )
24022411 {
24032412 var caseValues = new Dictionary < string , CasePayrollValue > ( ) ;
2404- foreach ( var value in values )
2413+ if ( values != null )
24052414 {
2406- var periodValues = value . Value . Select ( x => new PeriodValue ( x . Item2 , x . Item3 , x . Item4 ) ) ;
2407- caseValues . Add ( value . Key , new ( value . Key , periodValues ) ) ;
2415+ foreach ( var value in values )
2416+ {
2417+ var periodValues = value . Value . Select ( x => new PeriodValue ( x . Item2 , x . Item3 , x . Item4 ) ) ;
2418+ caseValues . Add ( value . Key , new ( value . Key , periodValues ) ) ;
2419+ }
24082420 }
24092421 return new ( caseValues ) ;
24102422 }
24112423
24122424 /// <summary>Convert tuple values to a collector result</summary>
24132425 /// <param name="values">The tuple values</param>
24142426 /// <returns>The collector results</returns>
2415- public static List < CollectorResult > TupleToCollectorResults ( this List < Tuple < string ,
2427+ public static List < CollectorResult > TupleToCollectorResults ( this List < Tuple < string ,
24162428 Tuple < DateTime , DateTime > , decimal , List < string > , Dictionary < string , object > > > values ) =>
2429+ values == null ? new ( ) :
24172430 [
24182431 ..values . Select ( x => new CollectorResult
24192432 {
@@ -2431,6 +2444,7 @@ public static List<CollectorResult> TupleToCollectorResults(this List<Tuple<stri
24312444 /// <returns>The collector custom results</returns>
24322445 public static List < CollectorCustomResult > TupleToCollectorCustomResults (
24332446 this List < Tuple < string , string , Tuple < DateTime , DateTime > , decimal , List < string > , Dictionary < string , object > > > values ) =>
2447+ values == null ? new ( ) :
24342448 [
24352449 ..values . Select ( x => new CollectorCustomResult
24362450 {
@@ -2449,6 +2463,7 @@ public static List<CollectorCustomResult> TupleToCollectorCustomResults(
24492463 /// <returns>The wage type results</returns>
24502464 public static List < WageTypeResult > TupleToWageTypeResults
24512465 ( this List < Tuple < decimal , string , Tuple < DateTime , DateTime > , decimal , List < string > , Dictionary < string , object > > > values ) =>
2466+ values == null ? new ( ) :
24522467 [
24532468 ..values . Select ( x => new WageTypeResult
24542469 {
@@ -2467,6 +2482,7 @@ public static List<WageTypeResult> TupleToWageTypeResults
24672482 /// <returns>The wage type custom results</returns>
24682483 public static List < WageTypeCustomResult > TupleToWageTypeCustomResults (
24692484 this List < Tuple < decimal , string , string , Tuple < DateTime , DateTime > , decimal , List < string > , Dictionary < string , object > > > values ) =>
2485+ values == null ? new ( ) :
24702486 [
24712487 ..values . Select ( x => new WageTypeCustomResult
24722488 {
@@ -2486,6 +2502,7 @@ public static List<WageTypeCustomResult> TupleToWageTypeCustomResults(
24862502 /// <returns>The lookup brackets</returns>
24872503 public static List < LookupRangeBracket > TupleToLookupRangeBracketList (
24882504 List < Tuple < string , string , decimal , decimal , decimal ? > > brackets ) =>
2505+ brackets == null ? new ( ) :
24892506 [
24902507 ..brackets . Select ( x => new LookupRangeBracket
24912508 {
0 commit comments