PEP 321: Date/Time Parsing and Formatting
A.M. Kuchling
amk at amk.ca
Tue Nov 18 13:37:22 EST 2003
More information about the Python-list mailing list
Tue Nov 18 13:37:22 EST 2003
- Previous message (by thread): PEP 321: Date/Time Parsing and Formatting
- Next message (by thread): PEP 321: Date/Time Parsing and Formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 17 Nov 2003 18:55:20 +0100, Gerrit Holl <gerrit at nl.linux.org> wrote: > I think there should be a 'strptime' equivalent, on which the former > three input formats are build. I think the latter should be a class > method of Timedelta. Then, those examples would be used as such: There's already a _strptime module used internally by time.strptime(). It wouldn't be difficult to rearrange the module a little to have functions that returned datetime instances. Let's assume we add a strptime() method to date, time, and datetime. What happens when you provide a time or date where it's not useful e.g. date.strptime(..., '1992-10-15 12:05:32')? Does it raise an exception? Does it silently ignore the time data? Or is it illegal to use time-related specifiers such as %H with date.strptime, or date-related ones such as %m with time.strptime? > I prefer solution 2. I think it is the most object-oriented way. And we So do we have one parsing method -- strptime() -- or several, one for each variant date format? Perhaps the simplest thing is to just add strptime() for now. > though. Shouldn't datetime be a subclass of both date and time? Probably not; a time represents a time independent of any particular day, while a datetime is certainly tied to a day, so a subclass relationship doesn't make sense. I'm lukewarm about CVS or tar-style times ("12 hours ago" "yesterday"). They may be good command-line user interface, because you don't need to look up the current time and then figure out what time 18 hours ago was, but writing such command-line UIs probably isn't very common. --amk
- Previous message (by thread): PEP 321: Date/Time Parsing and Formatting
- Next message (by thread): PEP 321: Date/Time Parsing and Formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list