InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDTime.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Michael Easter
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Description:
24 // This class provides cross-platform time handling.
25 //
26 //========================================================================================
27 
28 #ifndef __IDTime__
29 #define __IDTime__
30 
31 // ----- Includes -----
32 #include "ATypes.h"
33 
34 class IPMStream;
35 
36 using namespace adobe::afl;
37 
38 
44 class IDTime
45 {
46 public:
47  typedef object_type data_type;
48 
49 #ifdef WINDOWS
50 
55  static FILETIME ATimeToFILETIME(ATime time);
56 
62  static ATime FILETIMEToATime(FILETIME& fileTime);
63 #elif MACINTOSH
64 
69  static CFAbsoluteTime ATimeToAbsoluteTime(ATime time);
70 
76  static ATime AbsoluteTimeToATime(CFAbsoluteTime time);
77 
88  static bool GetUTCDateTime(int32* year, int32* month, int32* day, int32* hour, int32* minute, int32* second);
89 
100  static std::time_t SetUTCDateTime(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second);
101 
102 #endif
103 
104 
109  IDTime();
110 
115  IDTime(ATime time);
116 
122  IDTime(const IDTime& time);
123 
128  virtual ~IDTime();
129 
136  IDTime& operator=(const IDTime& rhs);
137 
142  void Swap(IDTime& rhs);
143 
150  bool operator==(const IDTime& rhs) const;
151 
158  bool operator!=(const IDTime& rhs) const;
159 
166  bool operator<(const IDTime& rhs) const;
167 
174  bool operator>(const IDTime& rhs) const;
175 
179  void CurrentTime();
180 
185  void SetTime(ATime time);
186 
191  ATime GetTime() const;
192 
203  bool SetTime(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second);
204 
217  bool GetTime(int32* year, int32* month, int32* day, int32* hour, int32* minute, int32* second, int32* dayOfWeek = nil) const;
218 
226  bool DateToString(WideString& str, bool bShortform) const;
227 
234  bool TimeToString(WideString& str) const;
235 
242  bool IsValid() const;
243 
250  void ReadWrite(IPMStream* s);
251 
252 #ifdef MACINTOSH
253 
257  enum DateFormatStyle {
258  kDateFormatShortStyle = 0, //e.g. “11/23/37”
259  kDateFormatMediumStyle = 1, //e.g. “Nov 23, 1937”
260  kDateFormatLongStyle = 2, //e.g. “November 23, 1937”
261  kDateFormatFullStyle = 3 //e.g. “Tuesday, April 12, 1952 AD”
262  };
263 
271  bool MacDateToString(WideString& str, const DateFormatStyle& dateFormatStyle) const;
272 #endif
273 
274 private:
275  uint64 XferInt64(IPMStream *s, uint64 &value) const;
276 
277  ATime fTime;
278 };
279 
280 
282 extern const IDTime kInvalidIDTime;
283 
284 #endif // __IDTime__