doc/devdocs/modules/launcher/plugins/timedate.md
The 'Time and Date' plugin shows the date and time in different formats. For the date and time formats the plugin uses the culture setting in Windows, if the format is not commonly defined. The user can search for the system date/time or a custom date/time. The value of each result can be copied to clipboard.
Query examples:
time10:30 AMWeek number::10/10/2022Remarks
uumsftoaexcexfList of available formats
The following formats are currently available:
| Format | Example (Based on default settings) | As result | As input | Result as custom format only |--------------|-----------|------------|------------| | Time | 5:10 PM | x | x | | | Date | 3/5/2022 | x | x | | | Now | 3/5/2022 5:10 PM | x | x | | | Time UTC | 4:10 PM | x | x | | | Now UTC | 3/5/2022 4:10 PM | x | x | | | Unix Timestamp | 1646496622 | x | x | | | Unix Timestamp in milliseconds | 1646496622500 | x | x | | | Hour | 10 | x | | | | Minute | 30 | x | | | | Second | 45 | x | | | | Millisecond | 678 | x | | | | Day (Week day) | Saturday | x | | | | Day of the week | 6 | x | | | | Day of the month | 5 | x | | | | Day of the year | 64 | x | | | | Week of the month | 1 | x | | | | Week of the year (Calendar week, Week number) | 10 | x | | | | Month | March | x | | | | Month of the year | 3 | x | | | | Month and day | March 7 | x | x | | | Year | 2022 | x | | | | Era | AD | x | | | | Era abbreviation | A | x | | | | Month and year | March 2022 | x | x | | | Windows file time (Int64 number) | 637820976123938199 | x | x | | | Universal time format: YYYY-MM-DD hh:mm:ss| 2022-03-05 16:20:12Z | x | x | | | ISO 8601 | 2022-03-05T17:23:04 | x | x | | | ISO 8601 UTC | 2022-03-05T16:23:04 | x | x | | | ISO 8601 with time zone | 2022-03-05T17:23:04+01:00 | x | x | | | ISO 8601 UTC with time zone | 2022-03-05T16:23:04Z | x | x | | | RFC1123 | Sat, 05 Mar 2022 16:23:04 GMT | x | x | | | OLE Automation date | 45723.44143763889 | | x | x | | Excel's 1900 date value | 45723.44143763889 | | x | x | | Excel's 1904 date value | 44261.44143763889 | | x | x |
Custom format definition
The user can create its own formats. One per line in the settings text box. The format of each line is <name>=<syntax pattern>.
If the syntax pattern starting with UTC: then we use the UTC time instead of the local time.
As syntax pattern the pattern from DateTime.ToString() and the following custom pattern are available:
GetList() of the AvailableResultsList class.
The optional plugin settings are implemented via the ISettingProvider interface from Wox.Plugin project.
All available settings for the plugin are defined in the TimeDateSettings class of the plugin. The settings can be accessed everywhere in the plugin code via the static class instance TimeDateSettings.Instance.
We have the following settings that the user can configure to change the behavior of the plugin:
| Key | Type | Default value | Name | Description |
|---|---|---|---|---|
OnlyDateTimeNowGlobal | Checkbox | true | Show only 'Time', 'Date', and 'Now' result for system time on global queries | Regardless of this setting, for global queries the first word of the query has to be a complete match. |
TimeWithSeconds | Checkbox | false | Show time with seconds | This setting applies to the 'Time' and 'Now' result. |
DateWithWeekday | Checkbox | false | Show date with weekday and name of month | This setting applies to the 'Date' and 'Now' result. |
HideNumberMessageOnGlobalQuery | Checkbox | false | Hide 'Invalid number input' error message on global queries | |
CalendarFirstWeekRule | Combo box | -1 (Use system settings) | First week of the year | Configure the calendar rule for the first week of the year. |
FirstDayOfWeek | Combo box | -1 (Use system settings) | First day of the week | |
CustomFormats | Multiline text box | string.Empty | Custom formats | Use date and time string format syntax and DOW (Day of Week), WOM (Week of Month), WOY (Week of the year), EAB (Era abbreviation), WFT (Windows File Time), UXT (Unix Time), UMS (Unix Time in milliseconds), OAD (OLE Automation date), EXC (Excel's 1900 based date value), EXF (Excel's 1904 based date value). If the format starts with UTC:, then Universal Time (UTC) is used. (Use a backslash to escape format sequences and the backslash character as text.) |
AvailableResult.csAvailableResult class represents a time/date result/format that the user can search for.AvailableResultsList class.AvailableResultsList.csAvailableResultsList class contains the list of available formats/results in its method GetList().ResultHelper.csResultHelper class contains methods for some of the result features (tool tip, copy to clipboard) and the error result on incorrect number input.SelectStringFromResources() method for getting the resource strings based on the user input.
stringId which is the name of the string in the resource file. By default the word Now is automatically added at the end to get the string for a system time/date search.stringIdNow can be used to override the default behavior of the method.stringId to string.Empty and only stringIdNow to a valid string id.TimeAndDateHelper.csTimeAndDateHelper class contains methods to format/convert date and time formats/strings.first week day and first week of the year rule based on the current plugin settings.TimeDateSettings.csTimeDateSettings class provides access to all optional plugin settings.Instance that holds an instance of the class itself. This allows us to access the settings from everywhere in the plugin code without having additional parameters in our methods.SearchController.csSearchController encapsulates the methods needed to search and find matches.AvailableResultsList.cs class.; character.FuzzyMatching to get the matching formats, if the user searches for a specific format. The score is set based on the FuzzySearch result.On global queries the high score returned by FuzzySearch has negative impacts on the user experience and the search results priority/order of other plugins. To mitigate this we defined some matching requirements:
We have a Unit Test project that executes various test to ensure that the plugin works as expected.
ImageTests.csImageTests.cs class contains tests to validate that each result shows the expected and correct image.en-us while executing the tests.PluginSettingsTests.csPluginSettingsTests.cs class contains tests to validate that all settings exist and that they have the correct default values.QueryTests.csQueryTests.cs class contains tests to validate that the user gets the correct results when searching.,en-us while executing the tests.StringParserTests.csStringParserTests.cs class contains tests to validate that the typed string gets converted correctly into a DateTime object.en-us while executing the tests.TimeAndDateHelperTests.csTimeAndDateHelperTests.cs class contains tests to validate important methods form the TimeAndDateHelper class that are not used for string parsing.TimeDateResultTests.csTimeDateResultTests.cs class contains tests to validate that the time and date values are correctly formatted/calculated.en-us while executing the tests.