Landlord
Kongkuo (kongko)
17:13:37 in the Linux/Unix community/Program Development Zone
Struct TM tmptm;
Strptime ("20010101010101", "% Y % m % d % H % m % s", & tmptm) can convert strings to correct strings under Solaris
Time, but it cannot be written under hp unix.
UNIX can be used with separators, such as strptime ("01:01:01", "% Y-% m-% d
% H: % m: % s ", & tmptm ). Excuse me, in HP
Can strptime ("20010101010101", "% Y % m % d % H % m % s", & tmptm) be handled in UNIX?
What's the problem? Thank you.
Number of questions: 20. replies: 4
Top
1st Floor
Fierygnu (va_list)
Back to 23:45:17 score
15
Strptime is similar to sscanf. If it is not clearly defined, it must be implemented. Therefore, it is portable in strptime ("01:01:01", "% Y-% m-% d % H: % m: % s", & tmptm) mode. Top
2nd floor
Ouygg)
Back to 11:35:59 score
5
Struct tm t;
Setlocale (lc_time, "en_us.iso88591"); // ********* note that you must pay attention to the environment variables.
Strptime ("1:04:23 on 10/6/92", "% I: % m: % S % P on % d", & T );
The converted value is stored in the structure T as follows:
T. tm_sec = 23
T. tm_min = 4
T. tm_hour = 13
T. tm_mday = 6
T. tm_mon = 9
T. tm_year = 92
T. tm_wday = 2
T. tm_yday = 279
T. tm_isdst = 1
Haha ~~~ Score
Top
Third floor
Kongkuo (kongko)
Back to 12:50:22 score 0
Thanks to fierygnu, it is really not portable. Now we don't need to use strptime, because there are many such forms of dates to be processed, and now we have fixed the length of reading the year, month... string. It should not be an environment variable. Thank you, ouygg. Top
4th floor
Fierygnu (va_list)
Back to 12:52:48 score 0
If they are all in this form, sscanf is more convenient.