Use of strptime in HP UNIX

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.