1 // ============================================================================
7 // Test ACE_OS::strptime
12 // ============================================================================
14 #include "test_config.h"
15 #include "ace/OS_NS_string.h"
16 #include "ace/OS_NS_strings.h"
17 #include "ace/OS_NS_stdlib.h"
18 #include "ace/OS_NS_sys_time.h"
19 #include "ace/OS_NS_time.h"
25 // convert UTC time string to UTC ACE_Time_Value
27 const char* original_time
= "2008-06-21 23:45";
29 ACE_OS::strptime(original_time
, "%Y-%m-%d %H:%M", &lTime
);
30 lTime
.tm_isdst
= 0; // do not change due to daylight saving time
31 time_t lNewTime
= ACE_OS::mktime(&lTime
);
32 ACE_Time_Value
lValue(lNewTime
- ACE_OS::timezone(), 0); // do not change because of timezone
34 // convert UTC ACE_Time_Value to UTC time string
36 time_t time
= lValue
.sec();
38 if (ACE_OS::gmtime_r (&time
, &tm_time
) == 0 && errno
== ENOTSUP
)
40 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("gmtime_r is not supported on this platform\n")));
42 if (ACE_OS::strftime(lBuffer
, 128, "%Y-%m-%d %H:%M", &tm_time
) == 0 && errno
== ENOTSUP
)
44 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("strftime is not supported on this platform\n")));
46 else if (ACE_OS::strcmp (lBuffer
, original_time
) != 0)
48 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%C != %C\n"), lBuffer
, original_time
));
53 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("strptime_test succeeded\n")));
60 run_main (int, ACE_TCHAR
*[])
62 ACE_START_TEST (ACE_TEXT ("Bug_3432_Regression_Test"));
67 if ((result
= strptime_test ()) != 0)