xref: /haiku/headers/private/netservices/HttpTime.h (revision 70b63f18b32a7ae90e4ff49659ba3844ce4c9aa5)
1603e0bdfSNiels Sascha Reedijk /*
2603e0bdfSNiels Sascha Reedijk  * Copyright 2010 Haiku Inc. All rights reserved.
3603e0bdfSNiels Sascha Reedijk  * Distributed under the terms of the MIT License.
4603e0bdfSNiels Sascha Reedijk  */
5603e0bdfSNiels Sascha Reedijk #ifndef _B_HTTP_TIME_H_
6603e0bdfSNiels Sascha Reedijk #define _B_HTTP_TIME_H_
7603e0bdfSNiels Sascha Reedijk 
8603e0bdfSNiels Sascha Reedijk #include <ctime>
9603e0bdfSNiels Sascha Reedijk 
10603e0bdfSNiels Sascha Reedijk #include <DateTime.h>
11603e0bdfSNiels Sascha Reedijk #include <String.h>
12603e0bdfSNiels Sascha Reedijk 
13603e0bdfSNiels Sascha Reedijk namespace BPrivate {
14603e0bdfSNiels Sascha Reedijk 
15ce64ffdbSNiels Sascha Reedijk namespace Network {
16ce64ffdbSNiels Sascha Reedijk 
17603e0bdfSNiels Sascha Reedijk enum {
18603e0bdfSNiels Sascha Reedijk 	B_HTTP_TIME_FORMAT_PARSED = -1,
19603e0bdfSNiels Sascha Reedijk 	B_HTTP_TIME_FORMAT_RFC1123 = 0,
20603e0bdfSNiels Sascha Reedijk 	B_HTTP_TIME_FORMAT_PREFERRED = B_HTTP_TIME_FORMAT_RFC1123,
21603e0bdfSNiels Sascha Reedijk 	B_HTTP_TIME_FORMAT_COOKIE,
22603e0bdfSNiels Sascha Reedijk 	B_HTTP_TIME_FORMAT_RFC1036,
23603e0bdfSNiels Sascha Reedijk 	B_HTTP_TIME_FORMAT_ASCTIME
24603e0bdfSNiels Sascha Reedijk };
25603e0bdfSNiels Sascha Reedijk 
26603e0bdfSNiels Sascha Reedijk 
27603e0bdfSNiels Sascha Reedijk class BHttpTime {
28603e0bdfSNiels Sascha Reedijk public:
29603e0bdfSNiels Sascha Reedijk 						BHttpTime();
30603e0bdfSNiels Sascha Reedijk 						BHttpTime(BDateTime date);
31603e0bdfSNiels Sascha Reedijk 						BHttpTime(const BString& dateString);
32603e0bdfSNiels Sascha Reedijk 
33603e0bdfSNiels Sascha Reedijk 	// Date modification
34603e0bdfSNiels Sascha Reedijk 			void		SetString(const BString& string);
35603e0bdfSNiels Sascha Reedijk 			void		SetDate(BDateTime date);
36603e0bdfSNiels Sascha Reedijk 
37603e0bdfSNiels Sascha Reedijk 
38603e0bdfSNiels Sascha Reedijk 	// Date conversion
39603e0bdfSNiels Sascha Reedijk 			BDateTime	Parse();
40603e0bdfSNiels Sascha Reedijk 			BString		ToString(int8 format = B_HTTP_TIME_FORMAT_PARSED);
41603e0bdfSNiels Sascha Reedijk 
42603e0bdfSNiels Sascha Reedijk private:
43603e0bdfSNiels Sascha Reedijk 			BString		fDateString;
44603e0bdfSNiels Sascha Reedijk 			BDateTime	fDate;
45603e0bdfSNiels Sascha Reedijk 			int8		fDateFormat;
46603e0bdfSNiels Sascha Reedijk };
47603e0bdfSNiels Sascha Reedijk 
48ce64ffdbSNiels Sascha Reedijk } // namespace Network
49ce64ffdbSNiels Sascha Reedijk 
50ce64ffdbSNiels Sascha Reedijk } // namespace BPrivate
51*70b63f18SNiels Sascha Reedijk 
52603e0bdfSNiels Sascha Reedijk #endif // _B_HTTP_TIME_H_
53