예제 #1
0
        //public string End => _end;

        public FPTime(string time)
        {
            if (time == null)
            {
                throw new ArgumentNullException("FPTime constructor argument");
            }

            _theString = time;
            if (int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Milliseconds), out _millis))
            {
                while (_millis.ToString().Length < 3 && _millis != 0)
                {
                    _millis *= 10;
                }
                // LOOK UP REMINDER IN THE LINE Validate(); IN THIS CONSTRUCTOR
            }
            else
            {
                _millis = 0;
            }

            milliseconds_length_flag = RegExTime.Extrapolate(time, RegExTime.REX.Milliseconds).Length;
            if (!int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Year), out _YYYY))
            {
                _YYYY = 0;
            }
            if (!int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Month), out _MM))
            {
                _MM = 0;
            }
            if (!int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Day), out _DD))
            {
                _DD = 0;
            }
            Binder = RegExTime.Extrapolate(time, RegExTime.REX.Binder);
            if (!int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Hours), out _hour))
            {
                _hour = 0;
            }
            if (!int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Minutes), out _min))
            {
                _min = 0;
            }
            if (!int.TryParse(RegExTime.Extrapolate(time, RegExTime.REX.Seconds), out _sec))
            {
                _sec = 0;
            }

            //_end = new String(time.ToCharArray(), time.LastIndexOf("."), time.Length - time.LastIndexOf("."));
            _end = Ender = RegExTime.Extrapolate(time, RegExTime.REX.Ender);

            Validate();                                     // REMINDER: If _milis is greater than a thousand, this method will fix that
        }
예제 #2
0
        public static string IduceVrijeme(FPTime time, string trajanje)
        {
            string default_end = "Z";

            /*int min = 0, sec = 0, millis = 0;
             * if (trajanje.Contains("."))
             * {
             *  try
             *  {
             *      int index = trajanje.IndexOf(".");
             *      if (index < 0) throw new IndexingErrorExeption("Index can't be less than zero");
             *      if (!(int.TryParse(new String(trajanje.ToCharArray(), 0, index), out sec))) throw new IndexingErrorExeption("Index for dot missaligned");
             *      if (!(int.TryParse(new String(trajanje.ToCharArray(), index + 1, trajanje.Length-index-1), out millis))) throw new IndexingErrorExeption("Index for dot missaligned");
             *  }
             *  catch
             *  {
             *      throw new Exception("WTF: trajanje" + trajanje + "   ::   vrijeme_string: " + time._theString);
             *  }
             *
             *  if (sec > 59)
             *  {
             *      min = (int)(sec / 60);
             *      sec -= (min * 60);
             *      while (millis > 1000) millis /= 10;
             *      return FPTime.Sum(time, new FPTime(2000, 0, 0, 0, min, sec, millis, default_end)).GetTimeString();
             *  }
             * }
             * else
             * {
             *  if (!(int.TryParse(new String(trajanje.ToCharArray(), 0, trajanje.Length), out sec))) throw new IndexingErrorExeption("Index for dot missaligned");
             *  if (sec > 59)
             *  {
             *      min = (int)(sec / 60);
             *      sec -= (min * 60);
             *      while (millis > 1000) millis /= 10;
             *  }
             *  return FPTime.Sum(time, new FPTime(0, 0, 0, 0, min, sec, millis, default_end)).GetTimeString();
             * }*/

            return(FPTime.Sum(time, new FPTime(2000, 1, 1, 0, 0, RegExTime.GetFromDuration(trajanje, RegExTime.REX.Seconds), RegExTime.GetFromDuration(trajanje, RegExTime.REX.Milliseconds), "Z")).GetTimeString());

            return(string.Empty);
        }