Let's say I have this portion of code:
import wx
now = wx.DateTime.Now()
print (wx.DateTime.FormatISOCombined(now))
which gives something like
2021-03-02T20:47:53
OK. Now, instead of the T character, I want to use something else – lets' say a space, but not limited to. The documentation for FormatISOCombined(self, sep='T') says:
The sep parameter default value produces the result exactly corresponding to the ISO standard, but it can also be useful to use a space as separator if a more human-readable combined date-time representation is needed.
Parameters
sep (int) –
but I don't understand how should I read this.
I tried sep = ' '
which gives ... argument 2 has unexpected type 'str'
, which seems correct, as the Parameters description explicitly says (int); however, this is confusing versus the sep='T'
in the function definition.
I tried sep = 0x20
which gives ... argument 2 has unexpected type 'int'
, which is why I don't understand anything anymore.
So, how should I read the documentation ?
It's a bit of a mystery and probably either a bug or a documentation error.
The source code simply inserts the separator
between the date and time
wxString FormatISOCombined(char sep = 'T') const
{ return FormatISODate() + sep + FormatISOTime(); }
So pragmatically, you should probably do the same, at least you won't be breaking anything.
print (wx.DateTime.FormatISODate(now)+" "+wx.DateTime.FormatISOTime(now))
2021-03-03 09:15:05
Edit 2022:
Ran into this problem myself and the answer, weirdly, is that it is expecting a single
character bytes
object, so the real answer is:
>>> print (wx.DateTime.Now().FormatISOCombined(sep=b' '))
2022-12-07 17:29:24