コード例 #1
0
        // Change the seconds component only
        public virtual bool ChangeSecond(int newSecs)
        {
            long tsecs = _totalSeconds;
            int  hours, mins, secs;

            GetTime(out hours, out mins, out secs);
            var newTime = new DayTime(hours, mins, newSecs);

            _totalSeconds = newTime._totalSeconds;
            return(tsecs != _totalSeconds);
        }
コード例 #2
0
        // Change the hour component
        public bool ChangeHour(int newHour)
        {
            long tsecs = _totalSeconds;
            int  hours, mins, secs;

            GetTime(out hours, out mins, out secs);
            var newTime = new DayTime(newHour, mins, secs);

            newTime.CheckHours();
            _totalSeconds = newTime._totalSeconds;
            return(tsecs != _totalSeconds);
        }
コード例 #3
0
        public Declination ParseFromMeade(String s)
        {
            Declination result = new Declination();
            // LOGV2(DEBUG_GENERAL, F("Declination.Parse(%s)"), s.c_str());

            // Use the DayTime code to parse it...
            DayTime dt = DayTime.ParseFromMeade(s);

            // ...and then correct for hemisphere
            //result._totalSeconds = dt.TotalSeconds + (NORTHERN_HEMISPHERE? -(ArcSecondsPerHemisphere / 2) : (ArcSecondsPerHemisphere / 2));
            //LOGV3(DEBUG_GENERAL, F("Declination.Parse(%s) -> %s"), s.c_str(), result.ToString());
            result._totalSeconds = dt.TotalSeconds;
            return(result);
        }
コード例 #4
0
        public static DayTime ParseFromMeade(String s)
        {
            DayTime result = new DayTime();
            int     i      = 0;
            long    sgn    = 1;

            // LOGV2(DEBUG_MEADE, F("DayTime: Parse Coord from [%s]"), s.c_str());
            // Check whether we have a Math.Sign. This should be able to parse RA and DEC strings (RA never has a Math.Sign, and DEC should always have one).
            if ((s[i] == '-') || (s[i] == '+'))
            {
                sgn = s[i] == '-' ? -1 : +1;
                i++;
            }

            // Degs can be 2 or 3 digits
            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);

            // Third digit?
            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++;             // Skip seperator

            int mins = int.Parse(s.Substring(i, i + 2));
            // LOGV3(DEBUG_MEADE, F("DayTime: Minutes are [%s] -> mins=%d"), s.Substring(i, i + 2).c_str(), mins);
            int secs = 0;

            if (s.Length > i + 4)
            {
                secs = int.Parse(s.Substring(i + 3, i + 5));
                // 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);
            }
            // Get the Math.Signed total seconds specified....
            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);
        }
コード例 #5
0
 public DayTime(DayTime other)
 {
     _totalSeconds = other._totalSeconds;
 }
コード例 #6
0
 // Subtract another time, wrapping seconds, minutes and hours if needed
 public void SubtractTime(DayTime other)
 {
     _totalSeconds -= other._totalSeconds;
     CheckHours();
 }
コード例 #7
0
 // Add another time, wrapping seconds, minutes and hours if needed
 public void AddTime(DayTime other)
 {
     _totalSeconds += other._totalSeconds;
     CheckHours();
 }
コード例 #8
0
 public void SetTime(DayTime other)
 {
     _totalSeconds = other._totalSeconds;
     CheckHours();
 }