jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 *******************************************************************************
|
jpayne@69
|
5 * Copyright (C) 2004 - 2008, International Business Machines Corporation and
|
jpayne@69
|
6 * others. All Rights Reserved.
|
jpayne@69
|
7 *******************************************************************************
|
jpayne@69
|
8 */
|
jpayne@69
|
9
|
jpayne@69
|
10 #ifndef UTMSCALE_H
|
jpayne@69
|
11 #define UTMSCALE_H
|
jpayne@69
|
12
|
jpayne@69
|
13 #include "unicode/utypes.h"
|
jpayne@69
|
14
|
jpayne@69
|
15 #if !UCONFIG_NO_FORMATTING
|
jpayne@69
|
16
|
jpayne@69
|
17 /**
|
jpayne@69
|
18 * \file
|
jpayne@69
|
19 * \brief C API: Universal Time Scale
|
jpayne@69
|
20 *
|
jpayne@69
|
21 * There are quite a few different conventions for binary datetime, depending on different
|
jpayne@69
|
22 * platforms and protocols. Some of these have severe drawbacks. For example, people using
|
jpayne@69
|
23 * Unix time (seconds since Jan 1, 1970) think that they are safe until near the year 2038.
|
jpayne@69
|
24 * But cases can and do arise where arithmetic manipulations causes serious problems. Consider
|
jpayne@69
|
25 * the computation of the average of two datetimes, for example: if one calculates them with
|
jpayne@69
|
26 * <code>averageTime = (time1 + time2)/2</code>, there will be overflow even with dates
|
jpayne@69
|
27 * around the present. Moreover, even if these problems don't occur, there is the issue of
|
jpayne@69
|
28 * conversion back and forth between different systems.
|
jpayne@69
|
29 *
|
jpayne@69
|
30 * <p>
|
jpayne@69
|
31 * Binary datetimes differ in a number of ways: the datatype, the unit,
|
jpayne@69
|
32 * and the epoch (origin). We'll refer to these as time scales. For example:
|
jpayne@69
|
33 *
|
jpayne@69
|
34 * <table border="1" cellspacing="0" cellpadding="4">
|
jpayne@69
|
35 * <caption>Table 1: Binary Time Scales</caption>
|
jpayne@69
|
36 * <tr>
|
jpayne@69
|
37 * <th align="left">Source</th>
|
jpayne@69
|
38 * <th align="left">Datatype</th>
|
jpayne@69
|
39 * <th align="left">Unit</th>
|
jpayne@69
|
40 * <th align="left">Epoch</th>
|
jpayne@69
|
41 * </tr>
|
jpayne@69
|
42 *
|
jpayne@69
|
43 * <tr>
|
jpayne@69
|
44 * <td>UDTS_JAVA_TIME</td>
|
jpayne@69
|
45 * <td>int64_t</td>
|
jpayne@69
|
46 * <td>milliseconds</td>
|
jpayne@69
|
47 * <td>Jan 1, 1970</td>
|
jpayne@69
|
48 * </tr>
|
jpayne@69
|
49 * <tr>
|
jpayne@69
|
50 *
|
jpayne@69
|
51 * <td>UDTS_UNIX_TIME</td>
|
jpayne@69
|
52 * <td>int32_t or int64_t</td>
|
jpayne@69
|
53 * <td>seconds</td>
|
jpayne@69
|
54 * <td>Jan 1, 1970</td>
|
jpayne@69
|
55 * </tr>
|
jpayne@69
|
56 * <tr>
|
jpayne@69
|
57 * <td>UDTS_ICU4C_TIME</td>
|
jpayne@69
|
58 *
|
jpayne@69
|
59 * <td>double</td>
|
jpayne@69
|
60 * <td>milliseconds</td>
|
jpayne@69
|
61 * <td>Jan 1, 1970</td>
|
jpayne@69
|
62 * </tr>
|
jpayne@69
|
63 * <tr>
|
jpayne@69
|
64 * <td>UDTS_WINDOWS_FILE_TIME</td>
|
jpayne@69
|
65 * <td>int64_t</td>
|
jpayne@69
|
66 *
|
jpayne@69
|
67 * <td>ticks (100 nanoseconds)</td>
|
jpayne@69
|
68 * <td>Jan 1, 1601</td>
|
jpayne@69
|
69 * </tr>
|
jpayne@69
|
70 * <tr>
|
jpayne@69
|
71 * <td>UDTS_DOTNET_DATE_TIME</td>
|
jpayne@69
|
72 * <td>int64_t</td>
|
jpayne@69
|
73 * <td>ticks (100 nanoseconds)</td>
|
jpayne@69
|
74 *
|
jpayne@69
|
75 * <td>Jan 1, 0001</td>
|
jpayne@69
|
76 * </tr>
|
jpayne@69
|
77 * <tr>
|
jpayne@69
|
78 * <td>UDTS_MAC_OLD_TIME</td>
|
jpayne@69
|
79 * <td>int32_t or int64_t</td>
|
jpayne@69
|
80 * <td>seconds</td>
|
jpayne@69
|
81 * <td>Jan 1, 1904</td>
|
jpayne@69
|
82 *
|
jpayne@69
|
83 * </tr>
|
jpayne@69
|
84 * <tr>
|
jpayne@69
|
85 * <td>UDTS_MAC_TIME</td>
|
jpayne@69
|
86 * <td>double</td>
|
jpayne@69
|
87 * <td>seconds</td>
|
jpayne@69
|
88 * <td>Jan 1, 2001</td>
|
jpayne@69
|
89 * </tr>
|
jpayne@69
|
90 *
|
jpayne@69
|
91 * <tr>
|
jpayne@69
|
92 * <td>UDTS_EXCEL_TIME</td>
|
jpayne@69
|
93 * <td>?</td>
|
jpayne@69
|
94 * <td>days</td>
|
jpayne@69
|
95 * <td>Dec 31, 1899</td>
|
jpayne@69
|
96 * </tr>
|
jpayne@69
|
97 * <tr>
|
jpayne@69
|
98 *
|
jpayne@69
|
99 * <td>UDTS_DB2_TIME</td>
|
jpayne@69
|
100 * <td>?</td>
|
jpayne@69
|
101 * <td>days</td>
|
jpayne@69
|
102 * <td>Dec 31, 1899</td>
|
jpayne@69
|
103 * </tr>
|
jpayne@69
|
104 *
|
jpayne@69
|
105 * <tr>
|
jpayne@69
|
106 * <td>UDTS_UNIX_MICROSECONDS_TIME</td>
|
jpayne@69
|
107 * <td>int64_t</td>
|
jpayne@69
|
108 * <td>microseconds</td>
|
jpayne@69
|
109 * <td>Jan 1, 1970</td>
|
jpayne@69
|
110 * </tr>
|
jpayne@69
|
111 * </table>
|
jpayne@69
|
112 *
|
jpayne@69
|
113 * <p>
|
jpayne@69
|
114 * All of the epochs start at 00:00 am (the earliest possible time on the day in question),
|
jpayne@69
|
115 * and are assumed to be UTC.
|
jpayne@69
|
116 *
|
jpayne@69
|
117 * <p>
|
jpayne@69
|
118 * The ranges for different datatypes are given in the following table (all values in years).
|
jpayne@69
|
119 * The range of years includes the entire range expressible with positive and negative
|
jpayne@69
|
120 * values of the datatype. The range of years for double is the range that would be allowed
|
jpayne@69
|
121 * without losing precision to the corresponding unit.
|
jpayne@69
|
122 *
|
jpayne@69
|
123 * <table border="1" cellspacing="0" cellpadding="4">
|
jpayne@69
|
124 * <tr>
|
jpayne@69
|
125 * <th align="left">Units</th>
|
jpayne@69
|
126 * <th align="left">int64_t</th>
|
jpayne@69
|
127 * <th align="left">double</th>
|
jpayne@69
|
128 * <th align="left">int32_t</th>
|
jpayne@69
|
129 * </tr>
|
jpayne@69
|
130 *
|
jpayne@69
|
131 * <tr>
|
jpayne@69
|
132 * <td>1 sec</td>
|
jpayne@69
|
133 * <td align="right">5.84542x10<sup>11</sup></td>
|
jpayne@69
|
134 * <td align="right">285,420,920.94</td>
|
jpayne@69
|
135 * <td align="right">136.10</td>
|
jpayne@69
|
136 * </tr>
|
jpayne@69
|
137 * <tr>
|
jpayne@69
|
138 *
|
jpayne@69
|
139 * <td>1 millisecond</td>
|
jpayne@69
|
140 * <td align="right">584,542,046.09</td>
|
jpayne@69
|
141 * <td align="right">285,420.92</td>
|
jpayne@69
|
142 * <td align="right">0.14</td>
|
jpayne@69
|
143 * </tr>
|
jpayne@69
|
144 * <tr>
|
jpayne@69
|
145 * <td>1 microsecond</td>
|
jpayne@69
|
146 *
|
jpayne@69
|
147 * <td align="right">584,542.05</td>
|
jpayne@69
|
148 * <td align="right">285.42</td>
|
jpayne@69
|
149 * <td align="right">0.00</td>
|
jpayne@69
|
150 * </tr>
|
jpayne@69
|
151 * <tr>
|
jpayne@69
|
152 * <td>100 nanoseconds (tick)</td>
|
jpayne@69
|
153 * <td align="right">58,454.20</td>
|
jpayne@69
|
154 * <td align="right">28.54</td>
|
jpayne@69
|
155 * <td align="right">0.00</td>
|
jpayne@69
|
156 * </tr>
|
jpayne@69
|
157 * <tr>
|
jpayne@69
|
158 * <td>1 nanosecond</td>
|
jpayne@69
|
159 * <td align="right">584.5420461</td>
|
jpayne@69
|
160 * <td align="right">0.2854</td>
|
jpayne@69
|
161 * <td align="right">0.00</td>
|
jpayne@69
|
162 * </tr>
|
jpayne@69
|
163 * </table>
|
jpayne@69
|
164 *
|
jpayne@69
|
165 * <p>
|
jpayne@69
|
166 * These functions implement a universal time scale which can be used as a 'pivot',
|
jpayne@69
|
167 * and provide conversion functions to and from all other major time scales.
|
jpayne@69
|
168 * This datetimes to be converted to the pivot time, safely manipulated,
|
jpayne@69
|
169 * and converted back to any other datetime time scale.
|
jpayne@69
|
170 *
|
jpayne@69
|
171 *<p>
|
jpayne@69
|
172 * So what to use for this pivot? Java time has plenty of range, but cannot represent
|
jpayne@69
|
173 * .NET <code>System.DateTime</code> values without severe loss of precision. ICU4C time addresses this by using a
|
jpayne@69
|
174 * <code>double</code> that is otherwise equivalent to the Java time. However, there are disadvantages
|
jpayne@69
|
175 * with <code>doubles</code>. They provide for much more graceful degradation in arithmetic operations.
|
jpayne@69
|
176 * But they only have 53 bits of accuracy, which means that they will lose precision when
|
jpayne@69
|
177 * converting back and forth to ticks. What would really be nice would be a
|
jpayne@69
|
178 * <code>long double</code> (80 bits -- 64 bit mantissa), but that is not supported on most systems.
|
jpayne@69
|
179 *
|
jpayne@69
|
180 *<p>
|
jpayne@69
|
181 * The Unix extended time uses a structure with two components: time in seconds and a
|
jpayne@69
|
182 * fractional field (microseconds). However, this is clumsy, slow, and
|
jpayne@69
|
183 * prone to error (you always have to keep track of overflow and underflow in the
|
jpayne@69
|
184 * fractional field). <code>BigDecimal</code> would allow for arbitrary precision and arbitrary range,
|
jpayne@69
|
185 * but we do not want to use this as the normal type, because it is slow and does not
|
jpayne@69
|
186 * have a fixed size.
|
jpayne@69
|
187 *
|
jpayne@69
|
188 *<p>
|
jpayne@69
|
189 * Because of these issues, we ended up concluding that the .NET framework's
|
jpayne@69
|
190 * <code>System.DateTime</code> would be the best pivot. However, we use the full range
|
jpayne@69
|
191 * allowed by the datatype, allowing for datetimes back to 29,000 BC and up to 29,000 AD.
|
jpayne@69
|
192 * This time scale is very fine grained, does not lose precision, and covers a range that
|
jpayne@69
|
193 * will meet almost all requirements. It will not handle the range that Java times do,
|
jpayne@69
|
194 * but frankly, being able to handle dates before 29,000 BC or after 29,000 AD is of very limited interest.
|
jpayne@69
|
195 *
|
jpayne@69
|
196 */
|
jpayne@69
|
197
|
jpayne@69
|
198 /**
|
jpayne@69
|
199 * <code>UDateTimeScale</code> values are used to specify the time scale used for
|
jpayne@69
|
200 * conversion into or out if the universal time scale.
|
jpayne@69
|
201 *
|
jpayne@69
|
202 * @stable ICU 3.2
|
jpayne@69
|
203 */
|
jpayne@69
|
204 typedef enum UDateTimeScale {
|
jpayne@69
|
205 /**
|
jpayne@69
|
206 * Used in the JDK. Data is a Java <code>long</code> (<code>int64_t</code>). Value
|
jpayne@69
|
207 * is milliseconds since January 1, 1970.
|
jpayne@69
|
208 *
|
jpayne@69
|
209 * @stable ICU 3.2
|
jpayne@69
|
210 */
|
jpayne@69
|
211 UDTS_JAVA_TIME = 0,
|
jpayne@69
|
212
|
jpayne@69
|
213 /**
|
jpayne@69
|
214 * Used on Unix systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value
|
jpayne@69
|
215 * is seconds since January 1, 1970.
|
jpayne@69
|
216 *
|
jpayne@69
|
217 * @stable ICU 3.2
|
jpayne@69
|
218 */
|
jpayne@69
|
219 UDTS_UNIX_TIME,
|
jpayne@69
|
220
|
jpayne@69
|
221 /**
|
jpayne@69
|
222 * Used in IUC4C. Data is a <code>double</code>. Value
|
jpayne@69
|
223 * is milliseconds since January 1, 1970.
|
jpayne@69
|
224 *
|
jpayne@69
|
225 * @stable ICU 3.2
|
jpayne@69
|
226 */
|
jpayne@69
|
227 UDTS_ICU4C_TIME,
|
jpayne@69
|
228
|
jpayne@69
|
229 /**
|
jpayne@69
|
230 * Used in Windows for file times. Data is an <code>int64_t</code>. Value
|
jpayne@69
|
231 * is ticks (1 tick == 100 nanoseconds) since January 1, 1601.
|
jpayne@69
|
232 *
|
jpayne@69
|
233 * @stable ICU 3.2
|
jpayne@69
|
234 */
|
jpayne@69
|
235 UDTS_WINDOWS_FILE_TIME,
|
jpayne@69
|
236
|
jpayne@69
|
237 /**
|
jpayne@69
|
238 * Used in the .NET framework's <code>System.DateTime</code> structure. Data is an <code>int64_t</code>. Value
|
jpayne@69
|
239 * is ticks (1 tick == 100 nanoseconds) since January 1, 0001.
|
jpayne@69
|
240 *
|
jpayne@69
|
241 * @stable ICU 3.2
|
jpayne@69
|
242 */
|
jpayne@69
|
243 UDTS_DOTNET_DATE_TIME,
|
jpayne@69
|
244
|
jpayne@69
|
245 /**
|
jpayne@69
|
246 * Used in older Macintosh systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value
|
jpayne@69
|
247 * is seconds since January 1, 1904.
|
jpayne@69
|
248 *
|
jpayne@69
|
249 * @stable ICU 3.2
|
jpayne@69
|
250 */
|
jpayne@69
|
251 UDTS_MAC_OLD_TIME,
|
jpayne@69
|
252
|
jpayne@69
|
253 /**
|
jpayne@69
|
254 * Used in newer Macintosh systems. Data is a <code>double</code>. Value
|
jpayne@69
|
255 * is seconds since January 1, 2001.
|
jpayne@69
|
256 *
|
jpayne@69
|
257 * @stable ICU 3.2
|
jpayne@69
|
258 */
|
jpayne@69
|
259 UDTS_MAC_TIME,
|
jpayne@69
|
260
|
jpayne@69
|
261 /**
|
jpayne@69
|
262 * Used in Excel. Data is an <code>?unknown?</code>. Value
|
jpayne@69
|
263 * is days since December 31, 1899.
|
jpayne@69
|
264 *
|
jpayne@69
|
265 * @stable ICU 3.2
|
jpayne@69
|
266 */
|
jpayne@69
|
267 UDTS_EXCEL_TIME,
|
jpayne@69
|
268
|
jpayne@69
|
269 /**
|
jpayne@69
|
270 * Used in DB2. Data is an <code>?unknown?</code>. Value
|
jpayne@69
|
271 * is days since December 31, 1899.
|
jpayne@69
|
272 *
|
jpayne@69
|
273 * @stable ICU 3.2
|
jpayne@69
|
274 */
|
jpayne@69
|
275 UDTS_DB2_TIME,
|
jpayne@69
|
276
|
jpayne@69
|
277 /**
|
jpayne@69
|
278 * Data is a <code>long</code>. Value is microseconds since January 1, 1970.
|
jpayne@69
|
279 * Similar to Unix time (linear value from 1970) and struct timeval
|
jpayne@69
|
280 * (microseconds resolution).
|
jpayne@69
|
281 *
|
jpayne@69
|
282 * @stable ICU 3.8
|
jpayne@69
|
283 */
|
jpayne@69
|
284 UDTS_UNIX_MICROSECONDS_TIME,
|
jpayne@69
|
285
|
jpayne@69
|
286 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
287 /**
|
jpayne@69
|
288 * The first unused time scale value. The limit of this enum
|
jpayne@69
|
289 * @deprecated ICU 59 The numeric value may change over time, see ICU ticket #12420.
|
jpayne@69
|
290 */
|
jpayne@69
|
291 UDTS_MAX_SCALE
|
jpayne@69
|
292 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
293
|
jpayne@69
|
294 } UDateTimeScale;
|
jpayne@69
|
295
|
jpayne@69
|
296 /**
|
jpayne@69
|
297 * <code>UTimeScaleValue</code> values are used to specify the time scale values
|
jpayne@69
|
298 * to <code>utmscale_getTimeScaleValue</code>.
|
jpayne@69
|
299 *
|
jpayne@69
|
300 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
301 *
|
jpayne@69
|
302 * @stable ICU 3.2
|
jpayne@69
|
303 */
|
jpayne@69
|
304 typedef enum UTimeScaleValue {
|
jpayne@69
|
305 /**
|
jpayne@69
|
306 * The constant used to select the units vale
|
jpayne@69
|
307 * for a time scale.
|
jpayne@69
|
308 *
|
jpayne@69
|
309 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
310 *
|
jpayne@69
|
311 * @stable ICU 3.2
|
jpayne@69
|
312 */
|
jpayne@69
|
313 UTSV_UNITS_VALUE = 0,
|
jpayne@69
|
314
|
jpayne@69
|
315 /**
|
jpayne@69
|
316 * The constant used to select the epoch offset value
|
jpayne@69
|
317 * for a time scale.
|
jpayne@69
|
318 *
|
jpayne@69
|
319 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
320 *
|
jpayne@69
|
321 * @stable ICU 3.2
|
jpayne@69
|
322 */
|
jpayne@69
|
323 UTSV_EPOCH_OFFSET_VALUE=1,
|
jpayne@69
|
324
|
jpayne@69
|
325 /**
|
jpayne@69
|
326 * The constant used to select the minimum from value
|
jpayne@69
|
327 * for a time scale.
|
jpayne@69
|
328 *
|
jpayne@69
|
329 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
330 *
|
jpayne@69
|
331 * @stable ICU 3.2
|
jpayne@69
|
332 */
|
jpayne@69
|
333 UTSV_FROM_MIN_VALUE=2,
|
jpayne@69
|
334
|
jpayne@69
|
335 /**
|
jpayne@69
|
336 * The constant used to select the maximum from value
|
jpayne@69
|
337 * for a time scale.
|
jpayne@69
|
338 *
|
jpayne@69
|
339 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
340 *
|
jpayne@69
|
341 * @stable ICU 3.2
|
jpayne@69
|
342 */
|
jpayne@69
|
343 UTSV_FROM_MAX_VALUE=3,
|
jpayne@69
|
344
|
jpayne@69
|
345 /**
|
jpayne@69
|
346 * The constant used to select the minimum to value
|
jpayne@69
|
347 * for a time scale.
|
jpayne@69
|
348 *
|
jpayne@69
|
349 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
350 *
|
jpayne@69
|
351 * @stable ICU 3.2
|
jpayne@69
|
352 */
|
jpayne@69
|
353 UTSV_TO_MIN_VALUE=4,
|
jpayne@69
|
354
|
jpayne@69
|
355 /**
|
jpayne@69
|
356 * The constant used to select the maximum to value
|
jpayne@69
|
357 * for a time scale.
|
jpayne@69
|
358 *
|
jpayne@69
|
359 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
360 *
|
jpayne@69
|
361 * @stable ICU 3.2
|
jpayne@69
|
362 */
|
jpayne@69
|
363 UTSV_TO_MAX_VALUE=5,
|
jpayne@69
|
364
|
jpayne@69
|
365 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
366 /**
|
jpayne@69
|
367 * The constant used to select the epoch plus one value
|
jpayne@69
|
368 * for a time scale.
|
jpayne@69
|
369 *
|
jpayne@69
|
370 * NOTE: This is an internal value. DO NOT USE IT. May not
|
jpayne@69
|
371 * actually be equal to the epoch offset value plus one.
|
jpayne@69
|
372 *
|
jpayne@69
|
373 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
374 *
|
jpayne@69
|
375 * @internal ICU 3.2
|
jpayne@69
|
376 */
|
jpayne@69
|
377 UTSV_EPOCH_OFFSET_PLUS_1_VALUE=6,
|
jpayne@69
|
378
|
jpayne@69
|
379 /**
|
jpayne@69
|
380 * The constant used to select the epoch plus one value
|
jpayne@69
|
381 * for a time scale.
|
jpayne@69
|
382 *
|
jpayne@69
|
383 * NOTE: This is an internal value. DO NOT USE IT. May not
|
jpayne@69
|
384 * actually be equal to the epoch offset value plus one.
|
jpayne@69
|
385 *
|
jpayne@69
|
386 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
387 *
|
jpayne@69
|
388 * @internal ICU 3.2
|
jpayne@69
|
389 */
|
jpayne@69
|
390 UTSV_EPOCH_OFFSET_MINUS_1_VALUE=7,
|
jpayne@69
|
391
|
jpayne@69
|
392 /**
|
jpayne@69
|
393 * The constant used to select the units round value
|
jpayne@69
|
394 * for a time scale.
|
jpayne@69
|
395 *
|
jpayne@69
|
396 * NOTE: This is an internal value. DO NOT USE IT.
|
jpayne@69
|
397 *
|
jpayne@69
|
398 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
399 *
|
jpayne@69
|
400 * @internal ICU 3.2
|
jpayne@69
|
401 */
|
jpayne@69
|
402 UTSV_UNITS_ROUND_VALUE=8,
|
jpayne@69
|
403
|
jpayne@69
|
404 /**
|
jpayne@69
|
405 * The constant used to select the minimum safe rounding value
|
jpayne@69
|
406 * for a time scale.
|
jpayne@69
|
407 *
|
jpayne@69
|
408 * NOTE: This is an internal value. DO NOT USE IT.
|
jpayne@69
|
409 *
|
jpayne@69
|
410 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
411 *
|
jpayne@69
|
412 * @internal ICU 3.2
|
jpayne@69
|
413 */
|
jpayne@69
|
414 UTSV_MIN_ROUND_VALUE=9,
|
jpayne@69
|
415
|
jpayne@69
|
416 /**
|
jpayne@69
|
417 * The constant used to select the maximum safe rounding value
|
jpayne@69
|
418 * for a time scale.
|
jpayne@69
|
419 *
|
jpayne@69
|
420 * NOTE: This is an internal value. DO NOT USE IT.
|
jpayne@69
|
421 *
|
jpayne@69
|
422 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
423 *
|
jpayne@69
|
424 * @internal ICU 3.2
|
jpayne@69
|
425 */
|
jpayne@69
|
426 UTSV_MAX_ROUND_VALUE=10,
|
jpayne@69
|
427
|
jpayne@69
|
428 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
429
|
jpayne@69
|
430 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
431 /**
|
jpayne@69
|
432 * The number of time scale values, in other words limit of this enum.
|
jpayne@69
|
433 *
|
jpayne@69
|
434 * @see utmscale_getTimeScaleValue
|
jpayne@69
|
435 * @deprecated ICU 59 The numeric value may change over time, see ICU ticket #12420.
|
jpayne@69
|
436 */
|
jpayne@69
|
437 UTSV_MAX_SCALE_VALUE=11
|
jpayne@69
|
438 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
439
|
jpayne@69
|
440 } UTimeScaleValue;
|
jpayne@69
|
441
|
jpayne@69
|
442 /**
|
jpayne@69
|
443 * Get a value associated with a particular time scale.
|
jpayne@69
|
444 *
|
jpayne@69
|
445 * @param timeScale The time scale
|
jpayne@69
|
446 * @param value A constant representing the value to get
|
jpayne@69
|
447 * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if arguments are invalid.
|
jpayne@69
|
448 * @return - the value.
|
jpayne@69
|
449 *
|
jpayne@69
|
450 * @stable ICU 3.2
|
jpayne@69
|
451 */
|
jpayne@69
|
452 U_STABLE int64_t U_EXPORT2
|
jpayne@69
|
453 utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErrorCode *status);
|
jpayne@69
|
454
|
jpayne@69
|
455 /* Conversion to 'universal time scale' */
|
jpayne@69
|
456
|
jpayne@69
|
457 /**
|
jpayne@69
|
458 * Convert a <code>int64_t</code> datetime from the given time scale to the universal time scale.
|
jpayne@69
|
459 *
|
jpayne@69
|
460 * @param otherTime The <code>int64_t</code> datetime
|
jpayne@69
|
461 * @param timeScale The time scale to convert from
|
jpayne@69
|
462 * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.
|
jpayne@69
|
463 *
|
jpayne@69
|
464 * @return The datetime converted to the universal time scale
|
jpayne@69
|
465 *
|
jpayne@69
|
466 * @stable ICU 3.2
|
jpayne@69
|
467 */
|
jpayne@69
|
468 U_STABLE int64_t U_EXPORT2
|
jpayne@69
|
469 utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status);
|
jpayne@69
|
470
|
jpayne@69
|
471 /* Conversion from 'universal time scale' */
|
jpayne@69
|
472
|
jpayne@69
|
473 /**
|
jpayne@69
|
474 * Convert a datetime from the universal time scale to a <code>int64_t</code> in the given time scale.
|
jpayne@69
|
475 *
|
jpayne@69
|
476 * @param universalTime The datetime in the universal time scale
|
jpayne@69
|
477 * @param timeScale The time scale to convert to
|
jpayne@69
|
478 * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.
|
jpayne@69
|
479 *
|
jpayne@69
|
480 * @return The datetime converted to the given time scale
|
jpayne@69
|
481 *
|
jpayne@69
|
482 * @stable ICU 3.2
|
jpayne@69
|
483 */
|
jpayne@69
|
484 U_STABLE int64_t U_EXPORT2
|
jpayne@69
|
485 utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status);
|
jpayne@69
|
486
|
jpayne@69
|
487 #endif /* #if !UCONFIG_NO_FORMATTING */
|
jpayne@69
|
488
|
jpayne@69
|
489 #endif
|
jpayne@69
|
490
|