[formatter] implement 'O' format specifier (#2736)

to apply a UTC offset to 'date' values and other datetime objects
This commit is contained in:
Mike Fährmann
2022-07-08 12:51:03 +02:00
parent e4f48cc810
commit 90ae48c40c
3 changed files with 56 additions and 1 deletions

View File

@@ -173,10 +173,16 @@ Format specifiers can be used for advanced formatting by using the options provi
<td><code>{updated:D%b %d %Y %I:%M %p/}</code></td>
<td><code>2010-01-01 00:00:00</code></td>
</tr>
<tr>
<td><code>O&lt;offset&gt;/</code></td>
<td>Apply <code>&lt;offset&gt;</code> to a <code>datetime</code> object, either as <code>±HH:MM</code> or <code>local</code> for local UTC offset</td>
<td><code>{date:O-06:30/}</code></td>
<td><code>2009-12-31 17:30:00</code></td>
</tr>
</tbody>
</table>
All special format specifiers (`?`, `L`, `J`, `R`, `D`) can be chained and combined with one another, but must always come before any standard format specifiers:
All special format specifiers (`?`, `L`, `J`, `R`, `D`, `O`) can be chained and combined with one another, but must always come before any standard format specifiers:
For example `{foo:?//RF/B/Ro/e/> 10}` -> `   Bee Bar`
- `?//` - Tests if `foo` has a value