📜 ⬆️ ⬇️

Cancel the transition to "winter" time

In connection with the abolition of the transition to “winter” time, development companies ask us questions related to possible problems that may arise with the correct operation of applications. To answer these questions, we prepared this material, which contains tips on using date / time functions correctly, checking the code to find potential problems, and describing the steps that need to be performed to correctly deploy the update of both the operating system and the applications themselves. . Below we will cover the following topics:


Introduction


In the summer of this year, the Government of the Russian Federation passed a law abolishing the seasonal rendition of hours and set the relevant time zones and time values. “Summer” and “winter” time, also called “seasonal time” or “Daylight Saving Time” (DST), is a time-calculating mode in which the clock is shifted one hour ahead in spring and one hour back in the fall. Spring and autumn transitions differ in the Northern and Southern Hemispheres. The transition to summer time in the Northern Hemisphere usually begins in March or April (depending on the country and continent), and the transition to winter time takes place in October or November. In the Southern Hemisphere, the opposite is true: “summer” time begins in October, and “winter” time begins in March or April. Note that the transition to "summer" and "winter" time does not occur in all countries.

Application Testing and Code Verification


The first step in preparing to cancel winter time is to install the appropriate operating system update, which is available at http://support.microsoft.com/kb/2570791 . Next, you need to make sure that the application works correctly with the new time zone settings and the disabled settings for the transition to "winter" and "summer" time. To do this, it is recommended to write a test script and compare the results of the application on a computer where the update has not yet been installed and on the computer with the update installed. If problems are found, it is recommended to check the application code, paying attention to the following functional blocks:The recommendations below will minimize the effect of canceling the transition to winter time and, in general, improve the work with date / time in applications.Below are some scenarios for using date / time functions that can be used to perform date / time conversions to a local representation.
')

Date / Time Conversion to Local View


There are a number of software interfaces in the Microsoft Windows operating system that can be used to convert UTC time to a local representation.Starting with the Microsoft Windows Vista operating system, the concept of “dynamic time zones” has been introduced - support for time zones with “start” and “end” DST dates floating from year to year. The rules for determining the start / end date are saved in the registry (see below) and can be obtained through the function GetDynamicTimeZoneInformation () , which fills the structure DYNAMIC _ TIME _ ZONE _ INFORMATION .

Using the .NET Framework


In the .NET Framework, there are classes for date / time conversion, which include the DateTime , TimeZone , TimeSpan, and DateTimeKind classes. These classes use the Windows API functions listed above. In addition to these functions, in the .NET Framework there are functions for changing the date / time to a specified interval - AddHours () , AddMinutes () , AddSeconds () , which are implemented in the DateTime class.

Time Zone Information


As we noted above, information about time zones is stored in the registry. Descriptions of all time zones can be found in the following registry branch:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Time Zones

Each time zone has its own unique element, the nested elements of which contain such attributes as the name of the official time zone, the formal name, as well as links to multilingual resources and, in fact, information about the time zone. The Dynamic DST nested element contains information about previous changes in time zones. Beginning with the Windows Vista operating system, this information is populated when the operating system is installed. For Windows XP and Windows Server 2003 operating systems, the information is filled in when installing the appropriate service packs.
Information about the current time zone selected in the Date and Time panel is also stored in the registry
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ TimeZoneInformation

Approaches to updating applications


Companies that develop software products should check the correctness of their applications after installing the update ( http://support.microsoft.com/kb/2570791 ), which cancels automatic switching of Windows to the "winter" time. The verification process is described above. If necessary, companies should release updates of their products, allowing to work correctly with the date / time after 10/30/2011.

Search for installed updates


To correctly install updates for your products, you need to make sure that the operating system update itself (KB2570791) is installed, because not all users have the Windows Update mechanism enabled and operating system updates are installed at the time of their appearance. Below are several ways to verify the installation of an operating system update (KB2570791).

Manual ways

To detect the fact that an operating system update has been installed (KB2570791), you can use the Windows Update section of the Control Panel . To do this, perform the following sequence of actions:
You can also use PowerShell to detect the fact that an operating system update has been installed (KB2570791). To find the OS update we are interested in, use the standard get- hotfix cmdlet as follows: PS C: \> get-hotfix KB2570791
Information about installed updates is also available through the Unified Operating System Management Interface - Windows Management Instrumentation (WMI). You can do this manually using the Windows Management Instrumentation Console (WMIC) utility. To get a list of all installed updates, run the wmic qfe list command and to find a specific operating system update, use the command
wmic qfe | find “2570791”

Software methods

Among the software methods, you can highlight a search in the registry, the use of the unified operating system management interface –WMI already mentioned, and the use of the Windows Update software interfaces. Search in the registry is not recommended, as in different versions of the operating system information is stored in different branches of the registry, for example, in recent versions of Windows, the Component Based Update section is used. The Windows Update programming interfaces are quite complex and should be used in cases when other methods are not suitable.
The easiest way to programmatically detect the fact that an operating system update is installed is WMI. To find all installed updates, you need to run a query.
select * from Win32_QuickFixEngineering and to find a specific update - the query select * from Win32_QuickFixEngineering where HotFixID = "KB2570791"
Further, if the operating system update is installed, the update of the software of the developer company is installed. If an update of the operating system is required, this can be done in one of the following ways:

Additional Information


/ AF

Source: https://habr.com/ru/post/130629/


All Articles