main/connectivity/source/drivers/dbase/DTable.cxx
/**
	calculates date time from the Julian Date
*/
calculates date time from the Julian Date
calculates date time from the Julian Date
void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,com::sun::star::util::DateTime& _rDateTime)
{
    if ( _nJulianDate )
    {
        sal_Int32 ialp;
	    sal_Int32 ka = _nJulianDate;
	    if ( _nJulianDate >= 2299161 )
	    {
		    ialp = (sal_Int32)( ((double) _nJulianDate - 1867216.25 ) / ( 36524.25 ));
		    ka = _nJulianDate + 1 + ialp - ( ialp >> 2 );
	    }
	    sal_Int32 kb = ka + 1524;
	    sal_Int32 kc =  (sal_Int32) ( ((double) kb - 122.1 ) / 365.25 );
	    sal_Int32 kd = (sal_Int32) ((double) kc * 365.25);
	    sal_Int32 ke = (sal_Int32) ((double) ( kb - kd ) / 30.6001 );
	    _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - ((sal_Int32) ( (double) ke * 30.6001 )));
	    if ( ke > 13 )
		    _rDateTime.Month = static_cast<sal_uInt16>(ke - 13);
	    else
		    _rDateTime.Month = static_cast<sal_uInt16>(ke - 1);
	    if ( (_rDateTime.Month == 2) && (_rDateTime.Day > 28) )
		    _rDateTime.Day = 29;
	    if ( (_rDateTime.Month == 2) && (_rDateTime.Day == 29) && (ke == 3) )
		    _rDateTime.Year = static_cast<sal_uInt16>(kc - 4716);
	    else if ( _rDateTime.Month > 2 )
		    _rDateTime.Year = static_cast<sal_uInt16>(kc - 4716);
	    else
		    _rDateTime.Year = static_cast<sal_uInt16>(kc - 4715);
    } 
    if ( _nJulianTime )
    {
        double d_s = _nJulianTime / 1000;
        double d_m = d_s / 60;
        double d_h  = d_m / 60;
        _rDateTime.Hours = (sal_uInt16) (d_h);
	    _rDateTime.Minutes = (sal_uInt16) d_m;			
	    _rDateTime.Seconds = static_cast<sal_uInt16>(( d_m - (double) _rDateTime.Minutes ) * 60.0);
    }
}
void lcl_CalDate ( sal_Int32 _nJulianDate , sal_Int32 _nJulianTime , com :: sun :: star :: util :: DateTime & _rDateTime ) { if ( _nJulianDate ) { sal_Int32 ialp ; sal_Int32 ka = _nJulianDate ; if ( _nJulianDate >= 2299161 ) { ialp = ( sal_Int32 ) ( ( ( double ) _nJulianDate - 1867216.25 ) / ( 36524.25 ) ) ; ka = _nJulianDate + 1 + ialp - ( ialp >> 2 ) ; } sal_Int32 kb = ka + 1524 ; sal_Int32 kc = ( sal_Int32 ) ( ( ( double ) kb - 122.1 ) / 365.25 ) ; sal_Int32 kd = ( sal_Int32 ) ( ( double ) kc * 365.25 ) ; sal_Int32 ke = ( sal_Int32 ) ( ( double ) ( kb - kd ) / 30.6001 ) ; _rDateTime . Day = static_cast < sal_uInt16 > ( kb - kd - ( ( sal_Int32 ) ( ( double ) ke * 30.6001 ) ) ) ; if ( ke > 13 ) _rDateTime . Month = static_cast < sal_uInt16 > ( ke - 13 ) ; else _rDateTime . Month = static_cast < sal_uInt16 > ( ke - 1 ) ; if ( ( _rDateTime . Month == 2 ) && ( _rDateTime . Day > 28 ) ) _rDateTime . Day = 29 ; if ( ( _rDateTime . Month == 2 ) && ( _rDateTime . Day == 29 ) && ( ke == 3 ) ) _rDateTime . Year = static_cast < sal_uInt16 > ( kc - 4716 ) ; else if ( _rDateTime . Month > 2 ) _rDateTime . Year = static_cast < sal_uInt16 > ( kc - 4716 ) ; else _rDateTime . Year = static_cast < sal_uInt16 > ( kc - 4715 ) ; } if ( _nJulianTime ) { double d_s = _nJulianTime / 1000 ; double d_m = d_s / 60 ; double d_h = d_m / 60 ; _rDateTime . Hours = ( sal_uInt16 ) ( d_h ) ; _rDateTime . Minutes = ( sal_uInt16 ) d_m ; _rDateTime . Seconds = static_cast < sal_uInt16 > ( ( d_m - ( double ) _rDateTime . Minutes ) * 60.0 ) ; } }
calculates date time from the Julian Date
calculates date time from the Julian Date
// if ( _nJulianDate ) // integer _aDateTime.Minutes //// weird: time fix //   int test = (_rDateTime.Hours % 3) * 100 + _rDateTime.Minutes; //int test_tbl[] = {0, 1, 2, 11, 12, 13, 22, 23, 24, 25, 34, 35, 36, //	45, 46, 47, 56, 57, 58, 107, 108, 109, 110, 119, 120, 121, //	130, 131, 132, 141, 142, 143, 152, 153, 154, 155, 204, 205, //	206, 215, 216, 217, 226, 227, 228, 237, 238, 239, 240, 249, //	250, 251}; //   for (int i = 0; i < sizeof(test_tbl)/sizeof(test_tbl[0]); i++) //{ //    if (test == test_tbl[i]) //    { //	// frac += 0.000012; //	    //d_hour = frac * 24.0; //	    _rDateTime.Hours = (sal_uInt16)d_hour; //	    d_minute = (d_hour - (double)_rDateTime.Hours) * 60.0; //	    _rDateTime.Minutes = (sal_uInt16)d_minute; //	    break; //    } //   }