Re: ICU4C, ICU4J API Proposal Universal Time Scale
Eric Mader <[email protected]> Thu, 28 Oct 2004 11:50:57 -0700
| Newsgroups | gmane.comp.lib.icu.general |
|---|---|
| Message-ID | <[email protected]> |
Here is the final version of the Universal Time Scale API's. I've dropped from(double) and toDouble() because clients can get the same effect themselves by casting, and int64 <-> double conversion in C is problematic on some platforms. I also added getTimeScaleValue(), which can be used to get information about a particular time scale. Regards, Eric Mader IBM GCoC - San José 5600 Cottle Rd. M/S 50-2/B11 San Jose, CA 95193
UniversalTimeScale.java
(text/java, 16.7 KB)
/*
**************************************************************************
* Copyright (C) 2004, International Business Machines Corporation and *
* others. All Rights Reserved. *
**************************************************************************
*
*/
package com.ibm.icu.util;
import com.ibm.icu.math.BigDecimal;
import com.ibm.icu.text.MessageFormat;
import java.lang.IllegalArgumentException;
/**
* There are quite a few different conventions for binary datetime, depending on different
* platforms and protocols. Some of these have severe drawbacks. For example, people using
* Unix time (seconds since Jan 1, 1970) think that they are safe until near the year 2038.
* But cases can and do arise where arithmetic manipulations causes serious problems. Consider
* the computation of the average of two datetimes, for example: if one calculates them with
* <code>averageTime = (time1 + time2)/2</code>, there will be overflow even with dates
* around the present. Moreover, even if these problems don't occur, there is the issue of
* conversion back and forth between different systems.
*
* <p>
* Binary datetimes differ in a number of ways: the datatype, the unit,
* and the epoch (origin). We'll refer to these as time scales. For example:
*
* <table border="1" cellspacing="0" cellpadding="4">
* <caption>
* <h3>Table 1: Binary Time Scales</h3>
*
* </caption>
* <tr>
* <th align="left">Source</th>
* <th align="left">Datatype</th>
* <th align="left">Unit</th>
* <th align="left">Epoch</th>
* </tr>
*
* <tr>
* <td>JAVA_TIME</td>
* <td>long</td>
* <td>milliseconds</td>
* <td>Jan 1, 1970</td>
* </tr>
* <tr>
*
* <td>UNIX_TIME</td>
* <td>int or long</td>
* <td>seconds</td>
* <td>Jan 1, 1970</td>
* </tr>
* <tr>
* <td>ICU4C</td>
*
* <td>double</td>
* <td>milliseconds</td>
* <td>Jan 1, 1970</td>
* </tr>
* <tr>
* <td>WINDOWS_FILE_TIME</td>
* <td>long</td>
*
* <td>ticks (100 nanoseconds)</td>
* <td>Jan 1, 1601</td>
* </tr>
* <tr>
* <td>WINDOWS_DATE_TIME</td>
* <td>long</td>
* <td>ticks (100 nanoseconds)</td>
*
* <td>Jan 1, 0001</td>
* </tr>
* <tr>
* <td>MAC_OLD_TIME</td>
* <td>int</td>
* <td>seconds</td>
* <td>Jan 1, 1904</td>
*
* </tr>
* <tr>
* <td>MAC_TIME</td>
* <td>double</td>
* <td>seconds</td>
* <td>Jan 1, 2001</td>
* </tr>
*
* <tr>
* <td>EXCEL_TIME</td>
* <td>?</td>
* <td>days</td>
* <td>Dec 31, 1899</td>
* </tr>
* <tr>
*
* <td>DB2_TIME</td>
* <td>?</td>
* <td>days</td>
* <td>Dec 31, 1899</td>
* </tr>
* </table>
*
* <p>
* All of the epochs start at 00:00 am (the earliest possible time on the day in question),
* and are assumed to be UTC.
*
* <p>
* The ranges for different datatypes are given in the following table (all values in years).
* The range of years includes the entire range expressible with positive and negative
* values of the datatype. The range of years for double is the range that would be allowed
* without losing precision to the corresponding unit.
*
* <table border="1" cellspacing="0" cellpadding="4">
* <tr>
* <th align="left">Units</th>
* <th align="left">long</th>
* <th align="left">double</th>
* <th align="left">int</th>
* </tr>
*
* <tr>
* <td>1 sec</td>
* <td align="right">5.84542×10¹¹</td>
* <td align="right">285,420,920.94</td>
* <td align="right">136.10</td>
* </tr>
* <tr>
*
* <td>1 millisecond</td>
* <td align="right">584,542,046.09</td>
* <td align="right">285,420.92</td>
* <td align="right">0.14</td>
* </tr>
* <tr>
* <td>1 microsecond</td>
*
* <td align="right">584,542.05</td>
* <td align="right">285.42</td>
* <td align="right">0.00</td>
* </tr>
* <tr>
* <td>100 nanoseconds (tick)</td>
* <td align="right">58,454.20</td>
* <td align="right">28.54</td>
* <td align="right">0.00</td>
* </tr>
* <tr>
* <td>1 nanosecond</td>
* <td align="right">584.5420461</td>
* <td align="right">0.2854</td>
* <td align="right">0.00</td>
* </tr>
* </table>
*
* <p>
* This class implements a universal time scale which can be used as a 'pivot',
* and provide conversion functions to and from all other major time scales.
* This datetimes to be converted to the pivot time, safely manipulated,
* and converted back to any other datetime time scale.
*
*<p>
* So what to use for this pivot? Java time has plenty of range, but cannot represent
* Windows datetimes without severe loss of precision. ICU4C time addresses this by using a
* <code>double</code> that is otherwise equivalent to the Java time. However, there are disadvantages
* with <code>doubles</code>. They provide for much more graceful degradation in arithmetic operations.
* But they only have 53 bits of accuracy, which means that they will lose precision when
* converting back and forth to ticks. What would really be nice would be a
* <code>long double</code> (80 bits -- 64 bit mantissa), but that is not supported on most systems.
*
*<p>
* The Unix extended time uses a structure with two components: time in seconds and a
* fractional field (microseconds). However, this is clumsy, slow, and
* prone to error (you always have to keep track of overflow and underflow in the
* fractional field). <code>BigDecimal</code> would allow for arbitrary precision and arbitrary range,
* but we would not want to use this as the normal type, because it is slow and does not
* have a fixed size.
*
*<p>
* Because of these issues, we ended up concluding that the Windows datetime would be the
* best pivot. However, we use the full range allowed by the datatype, allowing for
* datetimes back to 29,000 BC and up to 29,000 AD. This time scale is very fine grained,
* does not lose precision, and covers a range that will meet almost all requirements.
* It will not handle the range that Java times would, but frankly, being able to handle dates
* before 29,000 BC or after 29,000 AD is of very limited interest. However, for those cases,
* we also allow conversion to an optional <code>BigDecimal</code> format that would have arbitrary
* precision and range.
*
*/
public final class UniversalTimeScale
{
/**
* Used in the JDK. Data is a <code>long</code>. Value
* is milliseconds since January 1, 1970.
*
* @draft ICU 3.2
*/
public static final int JAVA_TIME = 0;
/**
* Used in Unix systems. Data is an <code>int> or a <code>long</code>. Value
* is seconds since January 1, 1970.
*
* @draft ICU 3.2
*/
public static final int UNIX_TIME = 1;
/**
* Used in the ICU4C. Data is a <code>double</code>. Value
* is milliseconds since January 1, 1970.
*
* @draft ICU 3.2
*/
public static final int ICU4C_TIME = 2;
/**
* Used in Windows for file times. Data is a <code>long</code>. Value
* is ticks (1 tick == 100 nanoseconds) since January 1, 1601.
*
* @draft ICU 3.2
*/
public static final int WINDOWS_FILE_TIME = 3;
/**
* Used in Windows for date time (?). Data is a <code>long</code>. Value
* is ticks (1 tick == 100 nanoseconds) since January 1, 0001.
*
* @draft ICU 3.2
*/
public static final int WINDOWS_DATE_TIME = 4;
/**
* Used in older Macintosh systems. Data is an <code>int</code>. Value
* is seconds since January 1, 1904.
*
* @draft ICU 3.2
*/
public static final int MAC_OLD_TIME = 5;
/**
* Used in the JDK. Data is a <code>double</code>. Value
* is milliseconds since January 1, 2001.
*
* @draft ICU 3.2
*/
public static final int MAC_TIME = 6;
/**
* Used in Excel. Data is a <code>?unknown?</code>. Value
* is days since December 31, 1899.
*
* @draft ICU 3.2
*/
public static final int EXCEL_TIME = 7;
/**
* Used in DB2. Data is a <code>?unknown?</code>. Value
* is days since December 31, 1899.
*
* @draft ICU 3.2
*/
public static final int DB2_TIME = 8;
/**
* This is the first unused time scale value.
*
* @draft ICU 3.2
*/
public static final int MAX_SCALE = 9;
/**
* The constant used to select the units vale
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
/**
* The constant used to select the units vale
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int UNITS_VALUE = 0;
/**
* The constant used to select the epoch offset value
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int EPOCH_OFFSET_VALUE = 1;
/**
* The constant used to select the minimum from value
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int FROM_MIN_VALUE = 2;
/**
* The constant used to select the maximum from value
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int FROM_MAX_VALUE = 3;
/**
* The constant used to select the minimum to value
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int TO_MIN_VALUE = 4;
/**
* The constant used to select the maximum to value
* for a time scale.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int TO_MAX_VALUE = 5;
/**
* The constant used to select the epoch plus one value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT. May not
* actually be equal to the epoch offset value plus one.
*
* @see getTimeScaleValue
*
* @draft ICU 3.2
*/
public static final int EPOCH_OFFSET_PLUS_1_VALUE = 6;
/**
* The constant used to select the epoch offset minus one value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT. May not
* actually be equal to the epoch offset value minus one.
*
* @see getTimeScaleValue
*
* @internal
*/
public static final int EPOCH_OFFSET_MINUS_1_VALUE = 7;
/**
* The constant used to select the units round value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see getTimeScaleValue
*
* @internal
*/
public static final int UNITS_ROUND_VALUE = 8;
/**
* The constant used to select the minimum safe rounding value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see getTimeScaleValue
*
* @internal
*/
public static final int MIN_ROUND_VALUE = 9;
/**
* The constant used to select the maximum safe rounding value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see getTimeScaleValue
*
* @internal
*/
public static final int MAX_ROUND_VALUE = 10;
/**
* The number of time scale values.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see getTimeScaleValue
*
* @internal
*/
public static final int MAX_SCALE_VALUE = 11;
/**
* Convert a <code>long</code> datetime from the given time scale to the universal time scale.
*
* @param otherTime The <code>long</code> datetime
* @param timeScale The time scale to convert from
*
* @return The datetime converted to the universal time scale
*
* @draft ICU 3.2
*/
public static long from(long otherTime, int timeScale);
/**
* Convert a <code>double</code> datetime from the given time scale to the universal time scale.
* All calculations are done using <code>BigDecimal</code> to guarantee that the value
* does not go out of range.
*
* @param otherTime The <code>double</code> datetime
* @param timeScale The time scale to convert from
*
* @return The datetime converted to the universal time scale
*
* @draft ICU 3.2
*/
public static BigDecimal bigDecimalFrom(double otherTime, int timeScale);
/**
* Convert a <code>long</code> datetime from the given time scale to the universal time scale.
* All calculations are done using <code>BigDecimal</code> to guarantee that the value
* does not go out of range.
*
* @param otherTime The <code>long</code> datetime
* @param timeScale The time scale to convert from
*
* @return The datetime converted to the universal time scale
*
* @draft ICU 3.2
*/
public static BigDecimal bigDecimalFrom(long otherTime, int timeScale);
/**
* Convert a <code>BigDecimal</code> datetime from the given time scale to the universal time scale.
* All calculations are done using <code>BigDecimal</code> to guarantee that the value
* does not go out of range.
*
* @param otherTime The <code>BigDecimal</code> datetime
* @param timeScale The time scale to convert from
*
* @return The datetime converted to the universal time scale
*
* @draft ICU 3.2
*/
public static BigDecimal bigDecimalFrom(BigDecimal otherTime, int timeScale);
/**
* Convert a datetime from the universal time scale stored as a <code>BigDecimal</code> to a
* <code>long</code> in the given time scale.
*
* Since this calculation requires a divide, we must round. The straight forward
* way to round by adding half of the divisor will push the sum out of range for values
* within have the divisor of the limits of the precision of a <code>long</code>. To get around this, we do
* the rounding like this:
*
* <p><code>
* (universalTime - units + units/2) / units + 1
* </code>
*
* <p>
* (i.e. we subtract units first to guarantee that we'll still be in range when we
* add <code>units/2</code>. We then need to add one to the quotent to make up for the extra subtraction.
* This simplifies to:
*
* <p><code>
* (universalTime - units/2) / units - 1
* </code>
*
* <p>
* For negative values to round away from zero, we need to flip the signs:
*
* <p><code>
* (universalTime + units/2) / units + 1
* </code>
*
* <p>
* Since we also need to subtract the epochOffset, we fold the <code>+/- 1</code>
* into the offset value. (i.e. <code>epochOffsetP1</code>, <code>epochOffsetM1</code>.)
*
* @param universal The datetime in the universal time scale
* @param timeScale The time scale to convert to
*
* @return The datetime converted to the given time scale
*
* @draft ICU 3.2
*/
public static long toLong(long universalTime, int timeScale);
/**
* Convert a datetime from the universal time scale to a <code>BigDecimal</code> in the given time scale.
*
* @param universal The datetime in the universal time scale
* @param timeScale The time scale to convert to
*
* @return The datetime converted to the given time scale
*
* @draft ICU 3.2
*/
public static BigDecimal toBigDecimal(long universalTime, int timeScale);
/**
* Convert a datetime from the universal time scale to a <code>BigDecimal</code> in the given time scale.
*
* @param universal The datetime in the universal time scale
* @param timeScale The time scale to convert to
*
* @return The datetime converted to the given time scale
*
* @draft ICU 3.2
*/
public static BigDecimal toBigDecimal(BigDecimal universalTime, int timeScale);
/**
* Get a value associated with a particular time scale.
*
* @param scale - the time scale
* @param value - a constant representing the value to get
*
* @return - the value.
*
* @draft ICU 3.2
*/
public static long getTimeScaleValue(int scale, int value);
/**
* Convert a time in the Universal Time Scale into another time
* scale. The division used to do the conversion rounds down.
*
* NOTE: This is an internal routine used by the tool that
* generates the to and from limits. Use it at your own risk.
*
* @param universalTime the time in the Universal Time scale
* @param timeScale the time scale to convert to
* @return the time in the given time scale
*
* @internal
*/
public static BigDecimal toBigDecimalTrunc(BigDecimal universalTime, int timeScale);
}
utmscale.h
(text/plain, 12.4 KB)
/*
*******************************************************************************
* Copyright (C) 2004, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/
#ifndef UTMSCALE_H
#define UTMSCALE_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
/**
* \file
* \brief C API: Universal Time Scale
*
* There are quite a few different conventions for binary datetime, depending on different
* platforms and protocols. Some of these have severe drawbacks. For example, people using
* Unix time (seconds since Jan 1, 1970) think that they are safe until near the year 2038.
* But cases can and do arise where arithmetic manipulations causes serious problems. Consider
* the computation of the average of two datetimes, for example: if one calculates them with
* <code>averageTime = (time1 + time2)/2</code>, there will be overflow even with dates
* around the present. Moreover, even if these problems don't occur, there is the issue of
* conversion back and forth between different systems.
*
* <p>
* Binary datetimes differ in a number of ways: the datatype, the unit,
* and the epoch (origin). We'll refer to these as time scales. For example:
*
* <table border="1" cellspacing="0" cellpadding="4">
* <caption>
* <h3>Table 1: Binary Time Scales</h3>
*
* </caption>
* <tr>
* <th align="left">Source</th>
* <th align="left">Datatype</th>
* <th align="left">Unit</th>
* <th align="left">Epoch</th>
* </tr>
*
* <tr>
* <td>JAVA_TIME</td>
* <td>int64_t</td>
* <td>milliseconds</td>
* <td>Jan 1, 1970</td>
* </tr>
* <tr>
*
* <td>UNIX_TIME</td>
* <td>int32_t or int64_t</td>
* <td>seconds</td>
* <td>Jan 1, 1970</td>
* </tr>
* <tr>
* <td>ICU4C_TIME</td>
*
* <td>double</td>
* <td>milliseconds</td>
* <td>Jan 1, 1970</td>
* </tr>
* <tr>
* <td>WINDOWS_FILE_TIME</td>
* <td>int64_t</td>
*
* <td>ticks (100 nanoseconds)</td>
* <td>Jan 1, 1601</td>
* </tr>
* <tr>
* <td>WINDOWS_DATE_TIME</td>
* <td>int64_t</td>
* <td>ticks (100 nanoseconds)</td>
*
* <td>Jan 1, 0001</td>
* </tr>
* <tr>
* <td>MAC_OLD_TIME</td>
* <td>int32_t</td>
* <td>seconds</td>
* <td>Jan 1, 1904</td>
*
* </tr>
* <tr>
* <td>MAC_TIME</td>
* <td>double</td>
* <td>seconds</td>
* <td>Jan 1, 2001</td>
* </tr>
*
* <tr>
* <td>EXCEL_TIME</td>
* <td>?</td>
* <td>days</td>
* <td>Dec 31, 1899</td>
* </tr>
* <tr>
*
* <td>DB2_TIME</td>
* <td>?</td>
* <td>days</td>
* <td>Dec 31, 1899</td>
* </tr>
* </table>
*
* <p>
* All of the epochs start at 00:00 am (the earliest possible time on the day in question),
* and are assumed to be UTC.
*
* <p>
* The ranges for different datatypes are given in the following table (all values in years).
* The range of years includes the entire range expressible with positive and negative
* values of the datatype. The range of years for double is the range that would be allowed
* without losing precision to the corresponding unit.
*
* <table border="1" cellspacing="0" cellpadding="4">
* <tr>
* <th align="left">Units</th>
* <th align="left">int64_t</th>
* <th align="left">double</th>
* <th align="left">int32_t</th>
* </tr>
*
* <tr>
* <td>1 sec</td>
* <td align="right">5.84542×10¹¹</td>
* <td align="right">285,420,920.94</td>
* <td align="right">136.10</td>
* </tr>
* <tr>
*
* <td>1 millisecond</td>
* <td align="right">584,542,046.09</td>
* <td align="right">285,420.92</td>
* <td align="right">0.14</td>
* </tr>
* <tr>
* <td>1 microsecond</td>
*
* <td align="right">584,542.05</td>
* <td align="right">285.42</td>
* <td align="right">0.00</td>
* </tr>
* <tr>
* <td>100 nanoseconds (tick)</td>
* <td align="right">58,454.20</td>
* <td align="right">28.54</td>
* <td align="right">0.00</td>
* </tr>
* <tr>
* <td>1 nanosecond</td>
* <td align="right">584.5420461</td>
* <td align="right">0.2854</td>
* <td align="right">0.00</td>
* </tr>
* </table>
*
* <p>
* These functions implement a universal time scale which can be used as a 'pivot',
* and provide conversion functions to and from all other major time scales.
* This datetimes to be converted to the pivot time, safely manipulated,
* and converted back to any other datetime time scale.
*
*<p>
* So what to use for this pivot? Java time has plenty of range, but cannot represent
* Windows datetimes without severe loss of precision. ICU4C time addresses this by using a
* <code>double</code> that is otherwise equivalent to the Java time. However, there are disadvantages
* with <code>doubles</code>. They provide for much more graceful degradation in arithmetic operations.
* But they only have 53 bits of accuracy, which means that they will lose precision when
* converting back and forth to ticks. What would really be nice would be a
* long double (80 bits -- 64 bit mantissa), but that is not supported on most systems.
*
*<p>
* The Unix extended time uses a structure with two components: time in seconds and a
* fractional field (microseconds). However, this is clumsy, slow, and
* prone to error (you always have to keep track of overflow and underflow in the
* fractional field). <code>BigDecimal</code> would allow for arbitrary precision and arbitrary range,
* but we do not want to use this as the normal type, because it is slow and does not
* have a fixed size.
*
*<p>
* Because of these issues, we ended up concluding that the Windows datetime would be the
* best pivot. However, we use the full range allowed by the datatype, allowing for
* datetimes back to 29,000 BC and up to 29,000 AD. This time scale is very fine grained,
* does not lose precision, and covers a range that will meet almost all requirements.
* It will not handle the range that Java times do, but frankly, being able to handle dates
* before 29,000 BC or after 29,000 AD is of very limited interest.
*
*/
/**
* <code>UDateTimeScale</code> values are used to specify the time scale used for
* conversion into or out if the universal time scale.
*
* @draft ICU 3.2
*/
typedef enum UDateTimeScale {
/**
* Used in the JDK. Data is a Java <code>long</code> (<code>int64_t</code>). Value
* is milliseconds since January 1, 1970.
*
* @draft ICU 3.2
*/
UDTS_JAVA_TIME = 0,
/**
* Used on Unix systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value
* is seconds since January 1, 1970.
*
* @draft ICU 3.2
*/
UDTS_UNIX_TIME,
/**
* Used in IUC4C. Data is a <code>double</code>. Value
* is milliseconds since January 1, 1970.
*
* @draft ICU 3.2
*/
UDTS_ICU4C_TIME,
/**
* Used in Windows for file times. Data is an <code>int64_t</code>. Value
* is ticks (1 tick == 100 nanoseconds) since January 1, 1601.
*
* @draft ICU 3.2
*/
UDTS_WINDOWS_FILE_TIME,
/**
* Used in Windows for dates and times (?). Data is an <code>int64_t</code>. Value
* is ticks (1 tick == 100 nanoseconds) since January 1, 0001.
*
* @draft ICU 3.2
*/
UDTS_WINDOWS_DATE_TIME,
/**
* Used in older Macintosh systems. Data is an <code>int32_t</code>. Value
* is seconds since January 1, 1904.
*
* @draft ICU 3.2
*/
UDTS_MAC_OLD_TIME,
/**
* Used in newer Macintosh systems. Data is a <code>double</code>. Value
* is seconds since January 1, 2001.
*
* @draft ICU 3.2
*/
UDTS_MAC_TIME,
/**
* Used in Excel. Data is an <code>?unknown?</code>. Value
* is days since December 31, 1899.
*
* @draft ICU 3.2
*/
UDTS_EXCEL_TIME,
/**
* Used in DB2. Data is an <code>?unknown?</code>. Value
* is days since December 31, 1899.
*
* @draft ICU 3.2
*/
UDTS_DB2_TIME,
/**
* The first unused time scale value.
*
* @draft ICU 3.2
*/
UDTS_MAX_SCALE
} UDateTimeScale;
typedef enum UTimeScaleValue {
/**
* The constant used to select the units vale
* for a time scale.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_UNITS_VALUE = 0,
/**
* The constant used to select the epoch offset value
* for a time scale.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_EPOCH_OFFSET_VALUE,
/**
* The constant used to select the minimum from value
* for a time scale.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_FROM_MIN_VALUE,
/**
* The constant used to select the maximum from value
* for a time scale.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_FROM_MAX_VALUE,
/**
* The constant used to select the minimum to value
* for a time scale.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_TO_MIN_VALUE,
/**
* The constant used to select the maximum to value
* for a time scale.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_TO_MAX_VALUE,
/**
* The constant used to select the epoch plus one value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT. May not
* actually be equal to the epoch offset value plus one.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_EPOCH_OFFSET_PLUS_1_VALUE,
/**
* The constant used to select the epoch plus one value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT. May not
* actually be equal to the epoch offset value plus one.
*
* @see utms_getTimeScaleValue
*
* @draft ICU 3.2
*/
UTSV_EPOCH_OFFSET_MINUS_1_VALUE,
/**
* The constant used to select the units round value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see utms_getTimeScaleValue
*
* @internal
*/
UTSV_UNITS_ROUND_VALUE,
/**
* The constant used to select the minimum safe rounding value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see utms_getTimeScaleValue
*
* @internal
*/
UTSV_MIN_ROUND_VALUE,
/**
* The constant used to select the maximum safe rounding value
* for a time scale.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see utms_getTimeScaleValue
*
* @internal
*/
UTSV_MAX_ROUND_VALUE,
/**
* The number of time scale values.
*
* NOTE: This is an internal value. DO NOT USE IT.
*
* @see utms_getTimeScaleValue
*
* @internal
*/
UTSV_MAX_SCALE_VALUE
} UTimeScaleValue;
/**
* Get a value associated with a particular time scale.
*
* @param timeScale The time scale
* @param value A constant representing the value to get
*
* @return - the value.
*
* @draft ICU 3.2
*/
U_DRAFT int64_t U_EXPORT2
utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErrorCode *status);
/* Conversion to 'universal time scale' */
/**
* Convert a <code>int64_t</code> datetime from the given time scale to the universal time scale.
*
* @param otherTime The <code>int64_t</code> datetime
* @param timeScale The time scale to convert from
* @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.
*
* @return The datetime converted to the universal time scale
*
* @draft ICU 3.2
*/
U_DRAFT int64_t U_EXPORT2
utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status);
/* Conversion from 'universal time scale' */
/**
* Convert a datetime from the universal time scale to a <code>int64_t</code> in the given time scale.
*
* @param universal The datetime in the universal time scale
* @param timeScale The time scale to convert to
* @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.
*
* @return The datetime converted to the given time scale
*
* @draft ICU 3.2
*/
U_DRAFT int64_t U_EXPORT2
utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif