1234567891011121314151617181920212223242526 |
- using System;
- using System.IO;
- using System.Linq;
- namespace BeatLyrics.Tool.Utils
- {
- internal static class Formatter
- {
- public static string FormatToTotalMinuteAndSeconds(this TimeSpan d) => $"{Math.Floor(d.TotalMinutes):00}:{d.Seconds:00}";
- public static string FormatToTotalMinuteAndSecondsAndMs(this TimeSpan d) => $"{Math.Floor(d.TotalMinutes):00}:{d.Seconds:00}.{d.Milliseconds:000}";
- public static string ToSafeFileName(this string str)
- {
- var inv = Path.GetInvalidFileNameChars();
- var chars = str.ToCharArray();
-
- for (var i = 0; i < chars.Length; i++)
- {
- if (inv.Contains(chars[i])) chars[i] = '_';
- }
- return new string(chars);
- }
- }
- }
|