From e61df546dd21d74af33b158e82feafde66a6d365 Mon Sep 17 00:00:00 2001 From: maxtwente Date: Thu, 7 Oct 2021 14:11:12 -0500 Subject: [PATCH] solution --- App/Program.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/App/Program.cs b/App/Program.cs index c4c26a8..7b7c539 100644 --- a/App/Program.cs +++ b/App/Program.cs @@ -1,4 +1,6 @@ using System; +using System.Globalization; +using System.Text.RegularExpressions; namespace App { @@ -11,12 +13,29 @@ static void Main(string[] args) public static string ConvertToTitleCase(string inpStr) { - return inpStr; + if (inpStr == null) + throw new Exception("input cannot be null"); + //creates a TextInfo based on the "en-US" culture. + TextInfo myTI = new CultureInfo("en-US", false).TextInfo; + //replace all alphanumeric with spaces + string outStr = Regex.Replace(inpStr, @"[^a-zA-Z0-9]+", " "); + //convert to titlecase and remove excess spaces at the end + return myTI.ToTitleCase(outStr.ToLower().Trim()); } public static string ConvertUnixToDateString(long? inpUnixSeconds) { - return inpUnixSeconds.ToString(); + try + { + //convert to DateTimeOffset + DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds((long)inpUnixSeconds); + //return formatted date + return dateTimeOffset.ToString("MMMM d, yyyy"); + } + catch + { + throw new Exception("invalid input"); + } } } } \ No newline at end of file