JSDDateTime::JSDDateTime(MJDDateTime& rhs) { CivilDateTime referenceCiv; /* Initialisation of the MJD reference day (01/01/2000, 0h00) */ referenceCiv.set_year(2000); referenceCiv.set_month(01); referenceCiv.set_day(01); referenceCiv.set_second(0); referenceCiv.set_decimal(0.0); /* JSD day of the ref. MJD date */ JSDDateTime referenceJSD(referenceCiv); /* JSD day computation */ JulianDate JD((double) rhs.get_day()); _day0hTU = referenceJSD.get_day0hTU() + JD; _second = referenceJSD.get_second() + (double) rhs.get_second(); _decimal = referenceJSD.get_decimal() + 0.000001 * (double) rhs.get_microsecond(); this->NormDate(); }
bool ossimCosmoSkymedModel::UtcDateTimeStringToCivilDate(const std::string &utcString, CivilDateTime &outputDate) { // conversion : // try with date format yyyymmdd if (utcString.size() < 8) return false ; const char* stringUTCDate = utcString.c_str() ; char year_str[5]; for (int i=0;i<4;i++) { year_str[i] = stringUTCDate[i]; } year_str[4] = '\0'; char month_str[3]; for (int i=4;i<6;i++) { month_str[i-4] = stringUTCDate[i]; } month_str[2] = '\0'; char day_str[3]; for (int i=6;i<8;i++) { day_str[i-6] = stringUTCDate[i]; } day_str[2] = '\0'; outputDate.set_year(atoi(year_str)); outputDate.set_month(atoi(month_str)); outputDate.set_day(atoi(day_str)); outputDate.set_second(0); outputDate.set_decimal(0.0); return true ; }
bool ossim::iso8601TimeStringToCivilDate(const std::string& dateString, CivilDateTime& outputDate) { bool result = true; ossimLocalTm otm; if ( otm.setIso8601(dateString) ) { outputDate.set_year( otm.getYear() ); outputDate.set_month( otm.getMonth() ); outputDate.set_day( otm.getDay() ); int second = otm.tm_hour * 3600 + otm.tm_min * 60 + otm.tm_sec; outputDate.set_second( second ); outputDate.set_decimal( otm.getFractionalSecond() ); } else { result = false; } return result; }