Kernel - NKS0024
Use TimeZones.GetCurrentZoneInfo()
This analyzer provides the following strings:
Error List
Caller uses TimeZoneInfo.Local
instead of TimeZones.GetCurrentZoneInfo()
Suggestion Box
Use TimeZones.GetCurrentZoneInfo()
instead of TimeZoneInfo.Local
Description
TimeZones.GetCurrentZoneInfo()
gets your local time zone and respects your kernel settings based on that. It either gets your local time zone from your system or from your kernel configuration.
Extended Description
This code analyzer detects the usage of Local
from the standard TimeZoneInfo
class found in the System
namespace.
TimeZoneInfo.Local
gives you a TimeZoneInfo
instance containing information about your computer's current timezone. However, the kernel has been given a brand new feature that allows you to choose your custom timezone without affecting the host system.
As a result, you should use TimeZones.GetCurrentZoneInfo()
as it respects your kernel settings regarding the timezone.
Analysis Comparison
To get a brief insight about how this analyzer works, compare the two code blocks shown to you below:
Before the fix
After the fix
Suppression
You can suppress this suggestion by including it in the appropriate place, whichever is convenient.
For more information about how to suppress any warning issued by the Nitrocid analyzer, visit the below page:
Recommendation
We recommend that every caller which use this function use the recommended abovementioned method.
Last updated