summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Helpers/TimeSpanHelper.cs
blob: 94d7629b9242473c81c5627f8e52ab4214ab2ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HandBrakeWPF.Helpers
{
    using System.Globalization;

    /// <summary>
    /// Helper functions for handling <see cref="TimeSpan"/> structures
    /// </summary>
    internal static class TimeSpanHelper
    {
        /// <summary>
        /// Parses chapter time start value from a chapter marker input file. 
        /// </summary>
        /// <param name="chapterStartRaw">The raw string value parsed from the input file</param>
        internal static TimeSpan ParseChapterTimeStart(string chapterStartRaw)
        {
            //Format: 02:35:05 and 02:35:05.2957333
            return TimeSpan.ParseExact(chapterStartRaw,
                                        new[]
                                        {
                                                    @"hh\:mm\:ss",  // Handle whole seconds
                                                    @"hh\:mm\:ss\.FFFFFFF"  // Handle fraction seconds
                                        }, CultureInfo.InvariantCulture);
        }
    }
}