AMX Date and Time formatting in code and on the panels
Technical Support Guide
Table of Contents
Displaying the date and time on touch panels and other user interfaces is a great addition for the end user, however the formatting available in the panel file doesn't always meet the needs of the user interface design (look and feel) or the preferences of the end user.
The date formats available on the panel are:
- weekday, example: Sunday
- mm/dd, example: 09/02
- dd/mm, example: 02/09
- mm/dd/yyyy, example: 09/02/2012
- dd/mm/yyyy, example: 02/09/2012
- mnth d, yyyy, example: September 2, 2012
- d mnth, yyyy, example: 2 September, 2012
- yyyy-mm-dd, example: 2012-10-05
The time formats available on the panel are:
- Standard, example: 3:36
- Standard AM/PM, example: 3:36 PM
- 24 hour, example: 15:36
Various questions about the date and time formatting have been asked.
For example:
- Is there a way to put the date and time on the same button?
- Is there a way to change the name of the month?
- Is there a way to change the names of the days of the week?
- Is there a way to only display the month?
- Is there a way to display a 2-digit year?
- Is there a way to change the delimiters?
Attached to this tech note is a workspace that contains an .axi file that can be incorporated into existing or new code that will display the date, time, or both on the panel in a custom format required to meet the needs of the panel design or the preferences of the end user.
An example workspace, master .axs file, and test panel file are included for demonstration purposes.
To quickly incorporate the .axi in the program,
- Copy the PanelDateTime.axi file into the working file directory.
- Add the include file to the workspace, using the "Existing Include" option.
- "Include" or "#Include" the file under the DEFINE_DEVICE section of the .axs file.
- Add the names of the panel devices, as called in DEFINE_DEVICE to the array dvDATETIMEPANELS found within the PanelDateTime.axi file
- Modify the panel files, by changing from an existing date or time port and address to an address that will not conflict with the existing design.
- Change the address numbers in the array nDATETIMEADDRESS found within the PanelDateTime.axi (if you don't want to use one enter a 0 in the array).
- Assign the appropriate formatting to the variables cDATEFORMAT, cTIMEFORMAT, or cDATETIMEFORMAT in the DEFINE_START section in the panel DateTime.axi.
- Compile .axs file.
- Load to the processor.
The PanelDateTime.axi file can be modified to meet the needs of the project. i.e. changing the names of the weekdays, or months, or by adding different formatting of the values