Example #1
0
        public static string IduceVrijeme(IFirePlaySong song)
        {
            string default_end = "Z";

            int min = 0, sec = 0, millis = 0;

            //int index = -1;
            if (song.Trajanje.Contains("."))
            {
                int index = song.Trajanje.IndexOf(".");
                if (!(int.TryParse(new String(song.Trajanje.ToCharArray(), 0, index), out sec)))
                {
                    throw new IndexingErrorExeption("Index for dot missaligned");
                }
                if (!(int.TryParse(new String(song.Trajanje.ToCharArray(), index + 1, song.Trajanje.Length), out millis)))
                {
                    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(new FPTime(song.Vrijeme), new FPTime(0, 0, 0, 0, min, sec, millis, default_end)).GetTimeString());
                }
            }
            else
            {
                if (!(int.TryParse(new String(song.Trajanje.ToCharArray(), 0, song.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(new FPTime(song.Vrijeme), new FPTime(0, 0, 0, 0, min, sec, millis, default_end)).GetTimeString());
                }
            }


            return(string.Empty);
        }
Example #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);
        }
Example #3
0
 public static string IduceVrijeme(FPTime time, int sec, int millis)
 {
     return(FPTime.Sum(time, new FPTime(2000, 0, 0, 0, 0, sec, millis, "Z")).GetTimeString());
 }