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