From af71e8898536c70ae9a99b6e9cc6b3505b3a6d43 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 22 Nov 2024 20:47:43 +1300 Subject: [PATCH] fixed time conversion --- .../_common/TypeReaders/Models/StoopidTime.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/EllieBot/_common/TypeReaders/Models/StoopidTime.cs b/src/EllieBot/_common/TypeReaders/Models/StoopidTime.cs index 0c5eca9..854dde7 100644 --- a/src/EllieBot/_common/TypeReaders/Models/StoopidTime.cs +++ b/src/EllieBot/_common/TypeReaders/Models/StoopidTime.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace EllieBot.Common.TypeReaders.Models; @@ -9,8 +8,8 @@ public class StoopidTime @"^(?:(?\d)mo)?(?:(?\d{1,2})w)?(?:(?\d{1,2})d)?(?:(?\d{1,4})h)?(?:(?\d{1,5})m)?(?:(?\d{1,6})s)?$", RegexOptions.Compiled | RegexOptions.Multiline); - public string Input { get; set; } - public TimeSpan Time { get; set; } + public string Input { get; set; } = string.Empty; + public TimeSpan Time { get; set; } = default; private StoopidTime() { } @@ -53,8 +52,8 @@ public class StoopidTime }; } - public static implicit operator TimeSpan(StoopidTime st) - => st.Time; + public static implicit operator TimeSpan?(StoopidTime? st) + => st?.Time; public static implicit operator StoopidTime(TimeSpan ts) => new()