Webtags/Parameters: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
2,189 bytes removed ,  18:10, 3 October 2022
m
(10 intermediate revisions by the same user not shown)
Line 147: Line 147:
# Next check [[#Which tag names take date/time output formatting modifiers|the next paragraph]] to see if that tag accepts both time and date modifiers
# Next check [[#Which tag names take date/time output formatting modifiers|the next paragraph]] to see if that tag accepts both time and date modifiers
# If your tag name does accept both date and time modifiers, simply modify the web tag as shown here <code><#tag_name format="yyyy-MM-dd HH:mm:ss"></code> where tag_name is set from step 1, but all the rest is typed as shown.
# If your tag name does accept both date and time modifiers, simply modify the web tag as shown here <code><#tag_name format="yyyy-MM-dd HH:mm:ss"></code> where tag_name is set from step 1, but all the rest is typed as shown.
# To explain each element in that format value, look in [[#Time formats]], [[#Year formats]], [[#Month formats]], [[#Day formats]], [[#Use of spaces]], [[#Including literals in format parameters]].
# To explain each element in that format value, look in [[#Time formats|Time formats]], [[#Year formats|Year formats]], [[#Month formats|Month formats]], [[#Day formats|Day formats]], [[#Use of spaces|Use of spaces]], [[#Including literals in format parameters|Including literals in format parameters]].


Should you want a different date/time format, then the sub-sections just referenced should help you to select a different arrangement, although there are some more options in [[#Date formats]].
Should you want a different date/time format, then the sub-sections just referenced should help you to select a different arrangement, although there are some more options in [[#Date formats]].
Line 242: Line 242:
All locales offer both numerical and alphabetical formats for representing a day.
All locales offer both numerical and alphabetical formats for representing a day.


[[File:Badge vMx.png]]Again, there are extra complications with MX, the "d" modifier is not shown because it is inconsistent, the format it returns depends on which tag name it is used with - see [[#Date formats]] table later! For some tag names it returns just "day of month" (like "%d"), for others it returns the full "Short date format" (like "ddddd")!
The table below shows the specifications for the day part of any date specifications. 


The table below is the definitive guide to how to ensure you do specify just the day part of any date specifications. 
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
!style="width:150px" | [[File:Badge v1.png]]}Delphi Specifier for Cumulus 1.9.x
!style="width:150px" | Specifier
!style="width:150px" | [[File:Badge vMx.png]]Mono/.NET Specifier for Cumulus MX
!style="width:600px" | Displays
!style="width:600px" | Displays
!style="width:600px" | Example
!style="width:600px" | Example
|-
|-
| d (single character)
| %d
| %d
|Displays the day as a number without a leading zero (1-31).  
|Displays the day as a number without a leading zero (1-31).  


[[File:Badge vMx.png]]Note that Cumulus MX requires a ' ' (space), '%' or another modifier to be included, as 'd' on its own is inconsistent - see [[#Date formats]] table).
Note that Cumulus MX requires '%' to be included, as 'd' on its own is inconsistent.
| 27 produced by:
|27 produced by <#metdate format="%d">
* [[File:Badge v1.png]]<#metdate format="d">
* [[File:Badge vMx.png]]<#metdate format="%d">
|-
|-
|dd (2 characters long)
|dd
|dd
|Displays the day as a number with a leading zero (01-31).
|Displays the day as a number with a leading zero (01-31).
|07 produced by <#metdate format="dd">
|07 produced by <#metdate format="dd">
|-
|-
|ddd (3 characters long)
|ddd
|ddd
|Displays the day as an abbreviation (in Australian will output "Sun." to "Sat.") using the strings appropriate to the Locale (see note for month abbreviation).
|Displays the day as an abbreviation using the strings appropriate to the Locale. It may produce a dot at the end of the string.
|'Wed' produced by <#metdate format="ddd"> (UK English locale)
|'Wed' produced by <#metdate format="ddd"> (UK English locale)
|-
|-
|dddd (4 characters long)
|dddd
|dddd
|Displays the day as a full name (Sunday-Saturday) using the strings appropriate to the Locale.
|Displays the day as a full name using the strings appropriate to the Locale.
|'Friday' produced by <#metdate format="dddd"> (English locale)
|'Friday' produced by <#metdate format="dddd"> (English locale)
|}
|}
Line 279: Line 271:
====Date formats====
====Date formats====


The [[#Year formats]], [[#Month formats]], and [[#Day formats]] listed above can be combined to make up a date output modifier, but there are some other modifiers available that can produce whole dates.
The [[#Year formats|Year formats]], [[#Month formats|Month formats]], and [[#Day formats|Day formats]] listed above can be combined to make up a date output modifier, but there are some other modifiers available that can produce whole dates.


[[#Locales]] will define a '''Short Date Format''' and a '''Long Date Format'''. You will see references to those in the table below explaining available output format modifiers, for example the single character output format modifier ('''G''' or '''c''') listed at the start of the table below.
The [[#Locales|locale]] will define a ''Short Date Format'' and a ''Long Date Format''. You will see references to those in the table below explaining available output format modifiers, for example the single character output format modifier ('''G''') listed at the start.


If you are in the USA, Cumulus will only use your month first date internally for the start date (see [[Cumulus.ini (Cumulus 1)]] and [[Cumulus.ini|Cumulus.ini (Cumulus MX)]]), that format will not be used in any files in the [[Data folder|'''data''' sub-folder]], but you can see your preferred format in the settings pages, in the extreme record editing pages, and by default as an output from many (not all) web tags.  For any web tags that do permit use of output date modification format parameters, you can can combine any month specifier, with any day of month specifier, in that order, to get an output where the month appears first (see example in table below).  
If you are in the USA, Cumulus will only use your month first date internally for the start date (see [[Cumulus.ini]]), that format will not be used in any files in the [[Data folder|data sub-folder]], but you can see your preferred format in the settings pages, in the extreme record editing pages, and by default as an output from many (not all) web tags.  For any web tags that do permit use of output date modification format parameters, you can can combine any month specifier, with any day of month specifier, in that order, to get an output where the month appears first (see example in table below).  


<big>Please could an American contributor please check if the "M" modifier works for their locale as shown and update the table below if necessary, and edit this comment into a confirmation</big>.
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
!style="width:150px" | [[File:Badge v1.png]]Delphi Specifier for Cumulus 1.9.x
!style="width:150px" | Specifier
!style="width:150px" | [[File:Badge vMx.png]]Mono/.NET Specifier for Cumulus MX
!style="width:600px" | Displays
!style="width:600px" | Displays
!style="width:600px" | Example
!style="width:600px" | Example
|-
|-
| c
| G
| G   (as single character format)
| Displays the date using the format given by the Short Date format, followed by the time using the format given by the Long Time format.  
| Displays the date using the format given by the Short Date format, followed by the time using the format given by the Long Time format. The time is not displayed in Cumulus 1 if the date-time value indicates midnight precisely.
| '22/03/2019 09:47:25' produced by <#time format=G>
| '22/03/2019 09:47:25' produced by [[File:Badge v1.png]]<#time format=c>[[File:Badge vMx.png]]<#time format=G>
|-
|-
| ddddd (5 characters long)
| ddddd
| ddddd (5 characters long)
| Displays the date using the format given by the Short Date format.
| 'ddddd' will output the date using the format given by the Short Date format.


[[File:Badge vMx.png]]'d' (when on its own, without space or '%' prefix) may or may not work, it displays inconsistent behaviour as its effect depends on the tag name (sorry, there is no definitive list from the MX author specifying effect by individual tag name) with which it is used (you will need to experiment for yourself and compare with the two examples).
Note: 'd' (when on its own, without '%' prefix) displays seemingly inconsistent behaviour as its effect depends on the tag name) with which it is used.
| * Short date format e.g. '22/03/2019' (British Locale) produced by <#metdate format=ddddd>
| '22/03/2019' (British Locale) produced by <#metdate format=ddddd>
* [[File:Badge vMx.png]] For some tag names can use "d":
** <#metdateyesterday format=d> e.g. '22/03/2019' (British Locale)
** <#yesterday=d> e.g. '22' returned
|-
|-
|dddddd (6 characters long)
|D
|D (as single character format)
|Displays the date using the format given by the Long Date format.   
|Displays the date using the format given by the Long Date format.   
 
| '22 March 2020' (British Locale)
[[File:Badge vMx.png]]The MX 'D' parameter '''cannot be combined''' with any other parameters.
|e.g. '22 March 2020' (British Locale)
|-
|-
|"D MMMM YYYY"
|D
|Long date format
|e.g.4 December 2009
|-
|"D MMMM"
|M
|M
|Day of month followed by Month name.   
|Day of month followed by Month name.   


[[File:Badge vMx.png]] Note this is different output to '''format=%M''' or ''format=" M"'' (see [[#Month formats]]). Not applicable to USA locales.
Note this is different output to '''format=%M''' (see [[#Month formats]]). Not applicable to USA locales.
| e.g. 22 July (English Locale)
| 22 July (English Locale)
|-
|"MMMM D"
|"MMMM d" if M alone does not work
| USA format of month before day of month
| e.g. July 4 (USA format)
|-
|-
|TT
|"MMMM d"
|T  (as single character format)
| USA format of month before day of month if M alone does not work
|Displays the time using the '''Long Time format'''.
| July 4 (USA format)
 
[[File:Badge vMx.png]] Note that this is a full time specifier and "T" is on its own as we are using a single character format.
|'09:47:56'  (might not use colon in your locale) produced by
* [[File:Badge v1.png]]<#LastDataReadT format=TT>
*[[File:Badge vMx.png]]<#LastDataReadT format=T>
|}
|}


====Time formats====
====Time formats====


Here context matters, so both standard (single character) and custom (two or more characters) formats are shown in the following table.  As explained earlier, time formats can be used with both time-duration reporting and clock time reporting.
Here context matters, so both standard (single character) and custom (two or more characters) formats are shown in the following table.  As explained earlier, time formats can be used with both time-duration reporting and clock time reporting.
Line 352: Line 319:
!style="width:600px" | Displays
!style="width:600px" | Displays
!style="width:600px" | Example
!style="width:600px" | Example
|-
|T  (as single character format)
|Displays the time using the '''Long Time format'''.
Note that this is a full time specifier and "T" is on its own as we are using a single character format.
|'09:47:56'  (might not use colon in your locale) produced by <#LastDataReadT format=T>
|-
|-
|%h
|%h
Line 469: Line 442:
|}
|}


==== Literals in scripts====
==== Literals ====
 
If you are considering use of literals (such as a space) within a output format modifier in a script, '''then don't'''.
 
Instead include whatever precedes the literal in a tag specification, then concatenate on the literal, and finally concatenate another tag specification for whatever is to follow the literal. 
 
An '''example''' to make this clearer is <code>$MXDateTime = '<#date format=yyyy-MM-dd>' . 'T' . '<#time format=hh:mm:ss>';</code>, which is written in PHP Hypertext Pre-processor format, the literal 'T' has been inserted by using two separate web tags surrounding the literal.  The same approach applies if you wanted to replace that "T" with a space.
NOTE: the same string is actually created by  <code>$MXDateTime = '<#date format=s>'</code>.


If you are considering use of literals (such as a space) within a output format modifier in a script, then don't. Instead include whatever precedes the literal in a tag specification, then concatenate on the literal, and finally concatenate another tag specification for whatever is to follow the literal.  An example to make this clearer is <code>$MXDateTime = '<#date format=yyyy-MM-dd>' . 'T' . '<#time format=hh:mm:ss>';</code>, which is written in PHP Hypertext Pre-processor format, the literal 'T' has been inserted by using two separate web tags surrounding the literal.  The same approach applies if you wanted to replace that "T" with a space.  (The explanation is that Cumulus (1 and MX) requires single quotes round a literal, but the script language requires any string to be enclosed in quotes, and double quotes are required by Cumulus round any complex specifier including any that include a space or other literal).
The reason is preventing complex mixup of single and double quotes between the script language and CumulusMX.


====Use of spaces====
====Use of spaces====

Navigation menu