There is a strptime
function in many language libraries (C, Python, Ruby, PHP, PERL, etc.).
It seems to be based on the Open Group's specification for time.h
.
I understand 'str' stands for string, and 'time' obviously stands for time, but what does the 'p' stand for? Parse? Pointer? Print?
Every time I reach for the strptime() function, I have a mental blank, and have to look up the name in a manual. I figure if I finally worked out what it stood for, perhaps I would have a chance of remembering it.
The strptime() function in Python is used to format and return a string representation of date and time. It takes in the date, time, or both as an input, and parses it according to the directives given to it. It raises ValueError if the string cannot be formatted according to the provided directives.
You might want to use these where times are irrelevant. strptime is short for "parse time" where strftime is for "formatting time". That is, strptime is the opposite of strftime though they use, conveniently, the same formatting specification.
Python time method strptime() parses a string representing a time according to a format. The return value is a struct_time as returned by gmtime() or localtime().
I guess it stands for "parse" because its reverse function is called strftime
in Python's time
module wherein the "f" I can reasonably guess stands for "format".
p = pointer. It returns a pointer to a char.
BTW According to my K&R there is a
char *strpbrk(cs,ct);
This 'p' also refers to the returned pointer.
I have same problem and I'm going with put:
strftime -> 'string from time'
strptime -> 'string, put time'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With