src/DayTime.cpp
// Parses the RA or DEC from a string that has an optional sign, a two digit degree, a seperator, a two digit minute, a seperator and a two digit second.
// Does not correct for hemisphere (derived class Declination takes care of that)
// For example:   -45*32:11 or 23:44:22
Parses the RA or DEC from a string that has an optional sign, a two digit degree, a seperator, a two digit minute, a seperator and a two digit second.
Does not correct for hemisphere (derived class Declination takes care of that)
For example:   -45*32:11 or 23:44:22
Parses the RA or DEC from a string that has an optional sign a two digit degree a seperator a two digit minute a seperator and a two digit second . Does not correct for hemisphere ( derived class Declination takes care of that ) For example : - 45 * 32 : 11 or 23 : 44 : 22
DayTime DayTime::ParseFromMeade(String s)
{
  DayTime result;
  int i = 0;
  long sgn = 1;
  LOGV2(DEBUG_MEADE, F("DayTime: Parse Coord from [%s]"), s.c_str());
  if ((s[i] == '-') || (s[i] == '+'))
  {
    sgn = s[i] == '-' ? -1 : +1;
    i++;
  }
  long degs = s[i++] - '0';
  LOGV3(DEBUG_MEADE, F("DayTime: 1st digit [%c] -> degs=%l"), s[i - 1], degs);
  degs = degs * 10 + s[i++] - '0';
  LOGV3(DEBUG_MEADE, F("DayTime: 2nd digit [%c] -> degs=%l"), s[i - 1], degs);
  if ((s[i] >= '0') && (s[i] <= '9'))
  {
    degs = degs * 10 + s[i++] - '0';
    LOGV3(DEBUG_MEADE, F("DayTime: 3rd digit [%c] -> degs=%d"), s[i - 1], degs);
  }
  i++; 
  int mins = s.substring(i, i + 2).toInt();
  LOGV3(DEBUG_MEADE, F("DayTime: Minutes are [%s] -> mins=%d"), s.substring(i, i + 2).c_str(), mins);
  int secs = 0;
  if (int(s.length()) > i + 4)
  {
    secs = s.substring(i + 3, i + 5).toInt();
    LOGV3(DEBUG_MEADE, F("DayTime: Seconds are [%s] -> secs=%d"), s.substring(i + 3, i + 5).c_str(), secs);
  }
  else
  {
    LOGV3(DEBUG_MEADE, F("DayTime: No Seconds. slen %d is not > %d"), s.length(), i + 4);
  }
  result.totalSeconds = sgn * (((degs * 60L + mins) * 60L) + secs);
  LOGV5(DEBUG_MEADE, F("DayTime: TotalSeconds are %l from %lh %dm %ds"), result.totalSeconds, degs, mins, secs);
  return result;
}
DayTime DayTime :: ParseFromMeade ( String s ) { DayTime result ; int i = 0 ; long sgn = 1 ; LOGV2 ( DEBUG_MEADE , F ( " " ) , s . c_str ( ) ) ; if ( ( s [ i ] == ' ' ) || ( s [ i ] == ' ' ) ) { sgn = s [ i ] == ' ' ? -1 : +1 ; i ++ ; } long degs = s [ i ++ ] - ' ' ; LOGV3 ( DEBUG_MEADE , F ( " " ) , s [ i - 1 ] , degs ) ; degs = degs * 10 + s [ i ++ ] - ' ' ; LOGV3 ( DEBUG_MEADE , F ( " " ) , s [ i - 1 ] , degs ) ; if ( ( s [ i ] >= ' ' ) && ( s [ i ] <= ' ' ) ) { degs = degs * 10 + s [ i ++ ] - ' ' ; LOGV3 ( DEBUG_MEADE , F ( " " ) , s [ i - 1 ] , degs ) ; } i ++ ; int mins = s . substring ( i , i + 2 ) . toInt ( ) ; LOGV3 ( DEBUG_MEADE , F ( " " ) , s . substring ( i , i + 2 ) . c_str ( ) , mins ) ; int secs = 0 ; if ( int ( s . length ( ) ) > i + 4 ) { secs = s . substring ( i + 3 , i + 5 ) . toInt ( ) ; LOGV3 ( DEBUG_MEADE , F ( " " ) , s . substring ( i + 3 , i + 5 ) . c_str ( ) , secs ) ; } else { LOGV3 ( DEBUG_MEADE , F ( " " ) , s . length ( ) , i + 4 ) ; } result . totalSeconds = sgn * ( ( ( degs * 60L + mins ) * 60L ) + secs ) ; LOGV5 ( DEBUG_MEADE , F ( " " ) , result . totalSeconds , degs , mins , secs ) ; return result ; }
Parses the RA or DEC from a string that has an optional sign, a two digit degree, a seperator, a two digit minute, a seperator and a two digit second.
Parses the RA or DEC from a string that has an optional sign a two digit degree a seperator a two digit minute a seperator and a two digit second .
// Check whether we have a sign. This should be able to parse RA and DEC strings (RA never has a sign, and DEC should always have one). // Degs can be 2 or 3 digits // Third digit? // Skip seperator // Get the signed total seconds specified....