blob: 73f3f491f399264bb8efb5d23575ae1e95c8c1a2 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TimeSpanHelper.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// Helper functions for handling <see cref="TimeSpan" /> structures
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Helpers
{
using System;
using System.Globalization;
using HandBrakeWPF.Services.Encode.Model.Models;
/// <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>
/// <returns>
/// The <see cref="TimeSpan"/>.
/// </returns>
internal static TimeSpan ParseChapterTimeStart(string chapterStartRaw)
{
if (string.IsNullOrEmpty(chapterStartRaw))
{
return TimeSpan.MinValue;
}
// Format: 02:35:05 and 02:35:05.2957333
TimeSpan converted;
string fromTime = chapterStartRaw.Trim().TrimEnd('0');
if (TimeSpan.TryParseExact(fromTime, new[] { @"HH\:mm\:ss", @"hh\:mm\:ss\.FFFFFFF", }, CultureInfo.InvariantCulture, out converted))
{
return converted;
}
return TimeSpan.Zero;
}
}
}
|