GlobalTester CustomTimeFormat Class
CustomTimeFormat Members
Defines how time values are formatted and displayed for the current user.
Constructors
| Name | Description | |
|
|
CustomTimeFormat | This class contains methods to customize time patterns, and AM/PM designators |
Methods
| Name | Description | |
|
|
ChangeShortTimeFormat(string) | Changes the short time formatting string. The maximum number of characters allowed for this string is 80, including a terminating null character. The string must consist of a combination of hour, minute, and second format pictures. |
|
|
ChangeLongTimeFormat(string) | Changes the long time formatting string. The maximum number of characters allowed for this string is 80, including a terminating null character. The string must consist of a combination of hour, minute, and second format pictures. |
|
|
ChangeAmSymbol(string) | Changes the string for the AM designator (first 12 hours of the day). The maximum number of characters allowed for this string, including a terminating null character is different for different releases of Windows. This method allows a maximum string length of 12 characters. |
|
|
ChangePmSymbol(string) | Changes the string for the PM designator (second 12 hours of the day). The maximum number of characters allowed for this string, including a terminating null character is different for different releases of Windows. This method allows a maximum string length of 12 characters. |
Exceptions
| Exception | Condition |
| ArgumentOutOfRange | The argument value exceeded the allowable range. |
Remarks
These methods customize the Time Formats on the Regional and Language control panel Time property sheet shown below.

Example
| namespace CustomizeTimeSettingsExample { using System; using TestingMentor.TestTool.GlobalTester; class MyTest { static void Main(string[] args) { CustomTimeFormat time = new CustomTimeFormat(); time.ChangeShortTimeFormat("h - m"); time.ChangeLongTimeFormat("HH,mm (ss) tt"); time.ChangeAmSymbol("Morning"); time.ChangePmSymbol("Afternoon"); // This launches the Region and Language control panel for demo purposes only System.Diagnostics.Process.Start("intl.cpl"); } } } |
This example changes the short time and long time formats and also changes the AM and PM designator symbols, then launches the Region and Language control panel to view the changes.
Example
| namespace CustomizeTimeSettingsExampleScript { using System; using System.Globalization; using TestingMentor.TestTool.GlobalTester; class MyTest { static void Main() { try { CustomTimeFormat time = new CustomTimeFormat(); string defaultLongTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern; string newLongTimeFormat = "HH,mm (ss) tt"; if (time.ChangeLongTimeFormat(newLongTimeFormat)) { // Launch AUT // Execute test - (e.g. AUT implements long time string) // Oracle - (e.g. compare long time format used in AUT against customized pattern) // Reset test platform to original configuration time.ChangeLongTimeFormat(defaultLongTimeFormat); } else { // Time format not changed; test not executed (e.g. invalid // hour, minute, and second format pictures) } } catch(ArgumentOutOfRange e) { // Test script failure - (e.g. long time format string argument out of range) } finally { // Log test results } } } } |
This example illustrates how customized time settings might be used in test automation to determine whether the AUT correctly implements the Windows NLS APIs and allows users to customize locale national conventions. After the test is complete the time format is reset to its default state.
Reference
Also See
CustomNumberFormat Class
CustomCurrencyFormat Class
CustomDateFormat Class
CustomLocation Class





