Example #1
0
 private static void CalculateDifferencies(BarBeatTimeSpan timeSpan1,
                                           BarBeatTimeSpan timeSpan2,
                                           out long barsDifference,
                                           out long beatsDifference,
                                           out long ticksDifference)
 {
     barsDifference  = timeSpan1.Bars - timeSpan2.Bars;
     beatsDifference = timeSpan1.Beats - timeSpan2.Beats;
     ticksDifference = timeSpan1.Ticks - timeSpan2.Ticks;
 }
Example #2
0
        internal static ParsingResult TryParse(string input, out BarBeatTimeSpan timeSpan)
        {
            timeSpan = null;

            if (string.IsNullOrWhiteSpace(input))
            {
                return(ParsingResult.EmptyInputString);
            }

            var match = ParsingUtilities.Match(input, Patterns);

            if (match == null)
            {
                return(ParsingResult.NotMatched);
            }

            long bars;

            if (!ParsingUtilities.ParseNonnegativeLong(match, BarsGroupName, 0, out bars))
            {
                return(ParsingResult.Error(BarsIsOutOfRange));
            }

            long beats;

            if (!ParsingUtilities.ParseNonnegativeLong(match, BeatsGroupName, 0, out beats))
            {
                return(ParsingResult.Error(BeatsIsOutOfRange));
            }

            long ticks;

            if (!ParsingUtilities.ParseNonnegativeLong(match, TicksGroupName, 0, out ticks))
            {
                return(ParsingResult.Error(TicksIsOutOfRange));
            }

            timeSpan = new BarBeatTimeSpan(bars, beats, ticks);
            return(ParsingResult.Parsed);
        }
Example #3
0
 /// <summary>
 /// Converts the string representation of a bar/beat time span to its <see cref="BarBeatTimeSpan"/>
 /// equivalent. A return value indicates whether the conversion succeeded.
 /// </summary>
 /// <param name="input">A string containing a time span to convert.</param>
 /// <param name="timeSpan">When this method returns, contains the <see cref="BarBeatTimeSpan"/>
 /// equivalent of the time span contained in <paramref name="input"/>, if the conversion succeeded, or
 /// null if the conversion failed. The conversion fails if the <paramref name="input"/> is null or
 /// <see cref="String.Empty"/>, is not of the correct format. This parameter is passed uninitialized;
 /// any value originally supplied in result will be overwritten.</param>
 /// <returns>true if <paramref name="input"/> was converted successfully; otherwise, false.</returns>
 public static bool TryParse(string input, out BarBeatTimeSpan timeSpan)
 {
     return(BarBeatTimeSpanParser.TryParse(input, out timeSpan).Status == ParsingStatus.Parsed);
 }