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
51 changes: 48 additions & 3 deletions App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Globalization;
using System.Text.RegularExpressions;


namespace App
{
public class Program
public static class Program
{
static void Main(string[] args)
{
Expand All @@ -11,12 +14,54 @@ static void Main(string[] args)

public static string ConvertToTitleCase(string inpStr)
{
return inpStr;

if(inpStr != null) {
Regex rgx = new Regex("[^a-zA-Z0-9 ]");
inpStr = rgx.Replace(inpStr, " "); //Find and replace all non-alphanumeric characters with spaces
inpStr = inpStr.Trim(); //Remove excess left on str
inpStr = inpStr.ToLower(); //Change entire string to lower case - easier to do that
// and convert first letter of each word to capital letter rather than find and replace each capital with a lower case.

inpStr = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(inpStr.ToLower());
return inpStr;
}
else{
throw new ArgumentException("Parameter cannot be null", nameof(inpStr));

}


}



public static string ConvertUnixToDateString(long? inpUnixSeconds)
{
return inpUnixSeconds.ToString();
String monthDay = "";
String year = "";

if(inpUnixSeconds.HasValue){
long inpUnixSeconds2 = inpUnixSeconds.GetValueOrDefault();
DateTime dateTime = (DateTimeOffset.FromUnixTimeSeconds(inpUnixSeconds2)).DateTime;
monthDay = dateTime.ToString("MMMM d");
year = dateTime.ToString("yyyy");


// let month = dateObj.toLocaleString('default', { month: 'long' });
// let day = dateObj.getDate();
// let year = dateObj.getFullYear();
// dateStr = month + " " + day + ", " + year;
}
else if(inpUnixSeconds == null){
throw new Exception();
}
else if(!inpUnixSeconds.HasValue){
monthDay = DateTime.Now.ToString("MMMM d");
year = DateTime.Now.ToString("yyyy");
}

return monthDay + ", " + year;

}
}
}