5,838
edits
m (→Use of spaces: Rewrite of last paragraph) |
m (→Use of spaces: ok, now finally the code shows correctly) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 206: | Line 206: | ||
===Use of spaces=== | ===Use of spaces=== | ||
There are multiple | There are multiple symbols for specifying dates and times, and you might want spaces to appear between symbols in that output format. | ||
You need to add quotation marks to the output format specifier if spaces are present. | |||
The first complication is that the parser that interprets time/date characters has two ways of interpreting a space character, depending on what immediately follows. In the tables, below, I have used a "%" in various places. In any of those places, a space is not a gap between characters, but an alternative to "%". I discuss this later in [[#Migrating from legacy Cumulus 1 to MX]] section. | |||
For | For a space character to be interpreted as a gap between symbols, the symbol that follows the space must include at least two characters. The syntax <code><#tag_name format="x y z"></code> works if the y and z in it are representing multi-character symbols. To explain this, an example is '''<#TpressTH format="h:mm tt">''' as both ''h:mm'' and ''tt'' are multi-character symbols, we have inserted a space after the minutes. | ||
That approach would not work if we wanted to use single character specifiers, a simple example is '''<#MonthPressHD format=" d' 'M">''', here the month number is a single character "M", so to insert the space we have to treat it as a literal by enclosing the space character in single quotes and the whole specifier in double quotes. Literals are discussed fully in the [[#Including literals in format parameters]] sub-section later. If we want to include other characters not to be interpreted by the date time parameter parser, and spaces, then both double and single quotes must be used, and the spaces must be within the single quotes. An example, that shows all the options that MX allows, with literals is <code> <#TpressH format="\a't 'h:mm' ' tt' <nowiki><small>on 'd/M/yyyy' </small></nowiki>'"> </code>. | |||
Finally, the use of literals can cause you ''a problem if you want to use a date/time specification in a script'' because the script wants literal delimiters outside any web tags, so that delimiters remain when the web tag itself has been processed into a string by Cumulus. This means the type of quotes (single or double) used outside the web tag, cannot be used within the web tag. The complicated sounding (but actually simple solution) is to avoid placing literals, and/or spaces, within any output format specifier, instead put single quotes round the whole content. What you thought of putting as literals within any web tag is instead typed outside with separate web tags for the part of the specification before and after each literal. | |||
===Which tag names take date/time output formatting modifiers=== | ===Which tag names take date/time output formatting modifiers=== | ||
Line 720: | Line 724: | ||
== Migrating | == Migrating from legacy Cumulus 1 to MX== | ||
If you | If you have created any legacy cumulus template files, then in each template, you will need to do some editing. Everywhere a web tag appears with an output modifiers that is used to specify a date and/or time format, has to be edited before that template will work for MX. | ||
Here are the main reasons: | |||
* the reserved characters are different in C1 and MX (affecting use of literals like "on" and "at" that appear in many English time-stamps) | * the reserved characters are different in C1 and MX (affecting use of literals like "on" and "at" that appear in many English time-stamps) | ||
* the Delphi in legacy Cumulus is case insensitive, so for example "H" and "h" have the same meaning | |||
* MX is case sensitive, and symbols mostly have different meanings when one symbol is used to when that symbol is used with others, so for example "H" and "h" have different meanings, and if not used with other symbols will need to be preceded with a "%" to have same meaning as they have in combination with other symbols | |||
* In the legacy cumulus, a symbol like "d" has the same meaning for any tag | |||
* MX is inconsistent, a symbol like "d" changes its meaning depending on the tag it is used with (e.g. the script conditional ''''<#metdateyesterday format=d>' == '<#yesterday format=d)>'''' will never be equal as the LHS returns a full date and the right hand side returns day of month only) | |||
* the symbols used for representing such modifiers as minutes, month, am/pm, are different between C1 and MX. | |||
* MX introduces the concept of escaping characters (a '''\''' placed before a character can be either a control sequence or an instruction to display the character) | * MX introduces the concept of escaping characters (a '''\''' placed before a character can be either a control sequence or an instruction to display the character) | ||
* | * In the legacy Cumulus, a space is a gap between characters | ||
* | * In MX, a space must be within a literal, as a space before a symbol has the same effect as "%", (it changes the interpretation of a modifier character). | ||
'''Confused even more now?''' I'm not surprised, but maybe some examples will help | '''Confused even more now?''' I'm not surprised, but maybe some examples will help. | ||
=== Examples === | === Examples === | ||
Line 753: | Line 762: | ||
** but alternatively you can escape each verbatim character with a backslash as prefix (Cumulus MX). | ** but alternatively you can escape each verbatim character with a backslash as prefix (Cumulus MX). | ||
* You may need to use both single quotes and back slashes in some format specifiers, depending whether the characters you want to include can be interpreted as control characters (yes, backslash is also used to escape control characters, so backslash will NOT work for some characters such as those in "on" and "at" [\n will produce new line not the letter n, \t will produce a tab not the letter t]), consequently for some characters you must use the literal approach to include them in your format. | * You may need to use both single quotes and back slashes in some format specifiers, depending whether the characters you want to include can be interpreted as control characters (yes, backslash is also used to escape control characters, so backslash will NOT work for some characters such as those in "on" and "at" [\n will produce new line not the letter n, \t will produce a tab not the letter t]), consequently for some characters you must use the literal approach to include them in your format. | ||
== Past history for this page== | == Past history for this page== |
edits