Skip to content

Add support for case modifiers to DateTime

Rick Calixte requested to merge rcalixte/glib:new_datetime_mods into main

This adds support for the strftime case modifiers ^ and # to DateTime.

JavaScript:

> GLib.DateTime.new_now_local().format("%A");
"Thursday"
> GLib.DateTime.new_now_local().format("%^A");
"THURSDAY"
> GLib.DateTime.new_now_local().format("%Z");
"EDT"
> GLib.DateTime.new_now_local().format("%#Z");
"edt"

Python3:

>>> GLib.DateTime.new_now_local().format("%A")
'Thursday'
>>> GLib.DateTime.new_now_local().format("%^A")
'THURSDAY'
>>> GLib.DateTime.new_now_local().format("%Z")
'EDT'
>>> GLib.DateTime.new_now_local().format("%#Z")
'edt'

date command:

$ date +"%A"
Thursday
$ date +"%^A"
THURSDAY

$ date +"%Z"
EDT
$ date +"%#Z"
edt

Tests for relevant case modifiers have been included as well.

Closes #3115 (closed)

Merge request reports