1804
|
1 /* This file is part of mingw-cross-env. */ |
|
2 /* See doc/index.html for further information. */ |
|
3 |
|
4 // |
|
5 // DateTime.cpp |
|
6 // |
|
7 // $Id: //poco/1.4/Foundation/samples/DateTime/src/DateTime.cpp#1 $ |
|
8 // |
|
9 // This sample demonstrates the DateTime class. |
|
10 // |
|
11 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
|
12 // and Contributors. |
|
13 // |
|
14 // Permission is hereby granted, free of charge, to any person or organization |
|
15 // obtaining a copy of the software and accompanying documentation covered by |
|
16 // this license (the "Software") to use, reproduce, display, distribute, |
|
17 // execute, and transmit the Software, and to prepare derivative works of the |
|
18 // Software, and to permit third-parties to whom the Software is furnished to |
|
19 // do so, all subject to the following: |
|
20 // |
|
21 // The copyright notices in the Software and this entire statement, including |
|
22 // the above license grant, this restriction and the following disclaimer, |
|
23 // must be included in all copies of the Software, in whole or in part, and |
|
24 // all derivative works of the Software, unless such copies or derivative |
|
25 // works are solely in the form of machine-executable object code generated by |
|
26 // a source language processor. |
|
27 // |
|
28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
29 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
30 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
|
31 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
|
32 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
|
33 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
34 // DEALINGS IN THE SOFTWARE. |
|
35 // |
|
36 |
|
37 |
|
38 #include "Poco/LocalDateTime.h" |
|
39 #include "Poco/DateTime.h" |
|
40 #include "Poco/DateTimeFormat.h" |
|
41 #include "Poco/DateTimeFormatter.h" |
|
42 #include "Poco/DateTimeParser.h" |
|
43 #include <iostream> |
|
44 |
|
45 |
|
46 using Poco::LocalDateTime; |
|
47 using Poco::DateTime; |
|
48 using Poco::DateTimeFormat; |
|
49 using Poco::DateTimeFormatter; |
|
50 using Poco::DateTimeParser; |
|
51 |
|
52 |
|
53 int main() |
|
54 { |
|
55 LocalDateTime now; |
|
56 |
|
57 std::string str = DateTimeFormatter::format(now, DateTimeFormat::ISO8601_FORMAT); |
|
58 DateTime dt; |
|
59 int tzd; |
|
60 DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, str, dt, tzd); |
|
61 dt.makeUTC(tzd); |
|
62 LocalDateTime ldt(tzd, dt); |
|
63 |
|
64 std::cerr << "Current time is " << str << std::endl; |
|
65 str = DateTimeFormatter::format(ldt, DateTimeFormat::ISO8601_FORMAT); |
|
66 std::cerr << "Parsed current time is " << str << std::endl; |
|
67 return 0; |
|
68 } |