Date Formatting Date and time text formatting for Real Time Clock (RTC) and FILE - "DATE" command. The formatting characters used to determine how a date is represented in a text variable or text entity are detailed below. It is possible to configure the textual strings representing the months of the year and days of the week to support different spoken languages. These are: short day text (ie "Mon", "Tue", ...), long day text (ie "Monday", "Tuesday", ...), suffix text (ie "st" for 1st, "nd" for 2nd, ...), short month text (ie "Jan", "Feb", ...), and long month text (ie "January", "February", ...). Some simple Date Formatting Examples are given using the FILE() command and reading the time of day from the RTC. Formatting Characters Time and date formatting is determined by passing a string of characters to the appropriate command. Each character, shown in the table below, represents a particular element of the time and date (such as hours or years) and how it is to be formatted (such as a number or text representation). Characters that do not appear in the table are simply returned in the string unmodified. This allows separating characters, such as ":", "/" and spaces, to be inserted into the string, e.g using the formatting string "d/m/Y H:i" would return a date formatted as "09/08/2012 21:45".
Changing Short Day Text The strings for the short textual representation of the day of the week are preconfigured in text variable entities but can be changed by the user (eg to support different languages). The following table summarises the suffixes.
These strings are variables of type TXT4 and have a maximum length of 4 characters. They can be accessed and changed, as any other text variable. For example: LOAD( DATE_MON_S, "Lun" ); // Change default "Mon" to "Lun" for French. Changing Long Day Text The strings for the long textual representation of the day of the week are preconfigured in text variable entities but can be changed by the user (eg to support different languages). The following table summarises the suffixes.
These strings are variables of type TXT16 and have a maximum length of 16 characters. They can be accessed and changed, as any other text variable. For example: LOAD( DATE_MON_L, "mercoled\\EC" ); // Change default "Wednesday" to "mercoledì" for Italian. Changing Suffix Text The strings for the ordinal suffixes for the day of month are preconfigured in text variable entities but can be changed by the user (eg to support different languages). The following table summarises the suffixes.
These strings are variables of type TXT4 and have a maximum length of 4 characters. They can be accessed and changed, as any other text variable. For example: LOAD( DATE_DM_RD, "RD" ); // Change default "rd" to uppercase "RD". Changing Short Month Text The strings for the short textual representation of the month of the year are preconfigured in text variable entities but can be changed by the user (eg to support different languages). The following table summarises the suffixes.
These strings are variables of type TXT4 and have a maximum length of 4 characters. They can be accessed and changed, as any other text variable. For example: LOAD( DATE_DEC_S, "Dez" ); // Change default "Dec" to "Dez" for German. Changing Long Month Text The strings for the long textual representation of the month of the year are preconfigured in text variable entities but can be changed by the user (eg to support different languages). The following table summarises the suffixes.
These strings are variables of type TXT16 and have a maximum length of 16 characters. They can be accessed and changed, as any other text variable. For example: LOAD( DATE_FEB_L, "febrero" ); // Change default "February" to "febrero" for Spanish. Date Formatting Examples Example 1 - FILE - "DATE" VAR( varTxt, "", TXT ); FILE( "DATE", , varTxt, "d/m/Y H:i:s", "SDHC/images/pic1.bmp" ); LOAD( RS2, "File Date:", varTxt ); // For example will send "File Date: 09/08/2012 21:19:32" Example 2 - RTC with VAR style formatting STYLE( stRtcTxt, data ) { type=text; maxLen=48; format="L F jS, Y g:i:s A"; } VAR( varTxt, "", stRtcTxt ); LOAD( varTxt, RTC ); LOAD( RS2, "Time is:", varTxt ); // For example will send "Time is: Thursday August 8th, 2012 9:19:32 PM" Example 3 - RTC with inline formatting VAR( varTxt, "", TXT ); LOAD( varTxt, %d-M-Y%RTC ); // Use special case formatting for RTC LOAD( RS2, "Day is:", varTxt ); // For example will send "Day is: 08-Aug-2012" |