subtle bug in the condition (#42633)
* subtle bug in the condition subtle bug in the condition used for checking if the store is open within the specified hours. Ensures that both conditions are checked logically (time must be both greater than or equal to the opening time and less than or equal to the closing time for the store to be considered open) * update output
This commit is contained in:
Родитель
9ec74a392f
Коммит
fadc18d0f8
|
@ -34,7 +34,7 @@ public struct StoreInfo
|
|||
storeDelta = tz.GetAdjustmentRules()[tz.GetAdjustmentRules().Length - 1].DaylightDelta;
|
||||
|
||||
TimeSpan comparisonTime = time + (offset - tz.BaseUtcOffset).Negate() + (delta - storeDelta).Negate();
|
||||
return comparisonTime >= open & comparisonTime <= close;
|
||||
return comparisonTime >= open && comparisonTime <= close;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Example
|
|||
// The example displays the following output:
|
||||
// Store is open now at 15:29:01.6129911: True
|
||||
// Store is open at 08:00:00: True
|
||||
// Store is open at 21:00:00: False
|
||||
// Store is open at 21:00:00: True
|
||||
// Store is open at 04:59:00: False
|
||||
// Store is open at 18:31:00: False
|
||||
// Store is open at 18:31:00: True
|
||||
// </Snippet2>
|
||||
|
|
Загрузка…
Ссылка в новой задаче