Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Globalization;
using System.Text.RegularExpressions;

namespace App
{
Expand All @@ -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");
}
}
}
}