Creating and updating seasons with an editor.

This commit is contained in:
2020-03-06 20:41:01 +01:00
parent 118c15f6c9
commit f3974807a8
12 changed files with 525 additions and 108 deletions

View File

@@ -0,0 +1,38 @@
using System.Text.RegularExpressions;
namespace EstusShots.Shared.Extensions
{
public static class StringExtensions
{
/// <summary>
/// Forces a string into the "yyyy-mm-dd" format
/// </summary>
/// <param name="this"></param>
/// <returns></returns>
public static string DateMask(this string @this)
{
// Remove all non-numbers
@this = Regex.Replace(@this, "[^0-9.]", "");
if (@this.Length < 8) @this += "????????";
return string.Format("{0}-{1}-{2}",
@this.Substring(0, 4), // The year,
@this.Substring(4, 2), // The month,
@this.Substring(6, 2)); // The day);
}
/// <summary>
/// Forces a string into the "HH:MM" format
/// </summary>
/// <param name="this"></param>
/// <returns></returns>
public static string HourMinuteMask(this string @this)
{
// Remove all non-numbers
@this = Regex.Replace(@this, "[^0-9.]", "");
if (@this.Length < 4) @this += "0000";
return string.Format("{0}:{1}",
@this.Substring(0, 2), // The hours,
@this.Substring(2, 4)); // The minutes
}
}
}