ICU-3927 remove utmscale_fromDouble(), utmscale_toDouble()

X-SVN-Rev: 16646
This commit is contained in:
Eric Mader 2004-10-27 21:28:38 +00:00
parent 054eeb6d70
commit 811ebbee0f
3 changed files with 0 additions and 225 deletions

View file

@ -426,20 +426,6 @@ U_DRAFT int64_t U_EXPORT2
/* Conversion to 'universal time scale' */
/**
* Convert a <code>double</code> datetime from the given time scale to the universal time scale.
*
* @param otherTime The <code>double</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_fromDouble(double otherTime, UDateTimeScale timeScale, UErrorCode *status);
/**
* Convert a <code>int64_t</code> datetime from the given time scale to the universal time scale.
*
@ -456,20 +442,6 @@ U_DRAFT int64_t U_EXPORT2
/* Conversion from 'universal time scale' */
/**
* Convert a datetime from the universal time scale to a <code>double</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 double U_EXPORT2
utmscale_toDouble(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status);
/**
* Convert a datetime from the universal time scale to a <code>int64_t</code> in the given time scale.
*

View file

@ -112,38 +112,6 @@ utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErr
}
}
U_CAPI int64_t U_EXPORT2
utmscale_fromDouble(double otherTime, UDateTimeScale timeScale, UErrorCode *status)
{
/*
* NOTE: fromMin and fromMax are marked "volatile" because the
* with the gcc compiler, the code which compares otherTime to
* fromMin and fromMax seems to fail if data->fromMax is U_INT64_MAX.
*/
const InternalTimeScaleData *data;
volatile double fromMin, fromMax;
if (status == NULL || U_FAILURE(*status)) {
return 0;
}
if (timeScale < 0 || timeScale >= UDTS_MAX_SCALE) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
data = &timeScaleTable[timeScale];
fromMin = (double) data->fromMin;
fromMax = (double) data->fromMax;
if (!(otherTime >= fromMin && otherTime <= fromMax)) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
return ((int64_t)otherTime + data->epochOffset) * data->units;
}
U_CAPI int64_t U_EXPORT2
utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status)
{
@ -168,42 +136,6 @@ utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *stat
return (otherTime + data->epochOffset) * data->units;
}
U_CAPI double U_EXPORT2
utmscale_toDouble(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status)
{
const InternalTimeScaleData *data;
if (status == NULL || U_FAILURE(*status)) {
return 0;
}
if (timeScale < 0 || timeScale >= UDTS_MAX_SCALE) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
data = &timeScaleTable[timeScale];
if (universalTime < data->toMin || universalTime > data->toMax) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
if (universalTime < 0) {
if (universalTime < data->minRound) {
return (double) (universalTime + data->unitsRound) / data->units - data->epochOffsetP1;
}
return (double) (universalTime - data->unitsRound) / data->units - data->epochOffset;
}
if (universalTime > data->maxRound) {
return (double) (universalTime - data->unitsRound) / data->units - data->epochOffsetM1;
}
return (double) (universalTime + data->unitsRound) / data->units - data->epochOffset;
}
U_CAPI int64_t U_EXPORT2
utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status)
{

View file

@ -142,16 +142,6 @@ static void epochOffsetTest(int64_t epochOffset, int64_t units, int32_t scale)
}
}
static double valueLessThan(double value)
{
return value - 100000.0;
}
static double valueGreaterThan(double value)
{
return value + 100000.0;
}
static void TestEpochOffsets(void)
{
UErrorCode status = U_ZERO_ERROR;
@ -195,62 +185,6 @@ static void TestToLimits(void)
}
}
static void TestFromDouble(void)
{
int32_t scale;
int64_t result;
UErrorCode status = U_ZERO_ERROR;
result = utmscale_fromDouble(0, -1, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(0, -1, status) did not set status to U_ILLEGAL_ARGUMENT_ERROR.\n");
}
for (scale = 0; scale < UDTS_MAX_SCALE; scale += 1) {
double fromMin, fromMax;
status = U_ZERO_ERROR;
fromMin = (double) utmscale_getTimeScaleValue(scale, UTSV_FROM_MIN_VALUE, &status);
fromMax = (double) utmscale_getTimeScaleValue(scale, UTSV_FROM_MAX_VALUE, &status);
status = U_ZERO_ERROR;
result = utmscale_fromDouble(0, scale, &status);
if (status == U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(0, %d, &status) generated U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
status = U_ZERO_ERROR;
result = utmscale_fromDouble(fromMin, scale, &status);
if (status == U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(fromMin, %d, &status) generated U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
status = U_ZERO_ERROR;
result = utmscale_fromDouble(valueLessThan(fromMin), scale, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(fromMin - 1, %d, &status) did not generate U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
status = U_ZERO_ERROR;
result = utmscale_fromDouble(fromMax, scale, &status);
if (status == U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(fromMax, %d, &status) generated U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
status = U_ZERO_ERROR;
result = utmscale_fromDouble(valueGreaterThan(fromMax), scale, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(fromMax + 1, %d, &status) didn't generate U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
}
status = U_ZERO_ERROR;
result = utmscale_fromDouble(0, UDTS_MAX_SCALE, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_fromDouble(0, UDTS_MAX_SCALE, &status) did not generate U_ILLEGAL_ARGUMENT_ERROR.\n");
}
}
static void TestFromInt64(void)
{
int32_t scale;
@ -311,67 +245,6 @@ static void TestFromInt64(void)
}
}
static void TestToDouble(void)
{
int32_t scale;
double result;
UErrorCode status = U_ZERO_ERROR;
result = utmscale_toDouble(0, -1, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(0, -1, &status) did not generate U_ILLEGAL_ARGUMENT_ERROR.\n");
}
for (scale = 0; scale < UDTS_MAX_SCALE; scale += 1) {
int64_t toMin, toMax;
status = U_ZERO_ERROR;
toMin = utmscale_getTimeScaleValue(scale, UTSV_TO_MIN_VALUE, &status);
toMax = utmscale_getTimeScaleValue(scale, UTSV_TO_MAX_VALUE, &status);
status = U_ZERO_ERROR;
result = utmscale_toDouble(0, scale, &status);
if (status == U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(0, %d, &status) generated U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
status = U_ZERO_ERROR;
result = utmscale_toDouble(toMin, scale, &status);
if (status == U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(toMin, %d, &status) generated U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
if (toMin > U_INT64_MIN) {
status = U_ZERO_ERROR;
result = utmscale_toDouble(toMin - 1, scale, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(toMin - 1, %d, &status) did not generate U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
}
status = U_ZERO_ERROR;
result = utmscale_toDouble(toMax, scale, &status);
if (status == U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(toMax, %d, &status) generated U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
if (toMax < U_INT64_MAX) {
status = U_ZERO_ERROR;
result = utmscale_toDouble(toMax + 1, scale, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(toMax + 1, %d, &status) did not generate U_ILLEGAL_ARGUMENT_ERROR.\n", scale);
}
}
}
status = U_ZERO_ERROR;
result = utmscale_toDouble(0, UDTS_MAX_SCALE, &status);
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("utmscale_toDouble(0, UDTS_MAX_SCALE, &status) did not generate U_ILLEGAL_ARGUMENT_ERROR.\n");
}
}
static void TestToInt64(void)
{
int32_t scale;
@ -435,9 +308,7 @@ static void TestToInt64(void)
static void TestAPI(void)
{
TestFromDouble();
TestFromInt64();
TestToDouble();
TestToInt64();
}