Updated daily report to show correct information when two work weeks split quarters.

Also current changes to project with Blazor implementation is implemented here as well.
This commit is contained in:
Daniel Wathen
2023-04-03 09:58:28 -07:00
parent f77d723576
commit 72e7a55ab4
305 changed files with 148901 additions and 4 deletions

View File

@ -0,0 +1,65 @@
using System.Text.RegularExpressions;
namespace ReportingServices.Shared.Blazor.HelperClasses;
public static class APIHelperFunctions
{
public static string GetBeginningOfWeekAsAPIString()
{
DateTime date = DateTime.Now;
int dayOfWeek = (int)date.DayOfWeek;
date = dayOfWeek switch
{
0 => date.AddDays(-6),
1 => date,
_ => date.AddDays(1 - dayOfWeek)
};
return GetDateTimeAsAPIString(date.ToString(), false);
}
public static string GetDateWithOffsetAsAPIString(string dateString, float offset)
{
DateTime date = DateTime.Parse(dateString);
date = date.AddHours(offset);
return GetDateTimeAsAPIString(date.ToString(), true);
}
public static string GetDateTimeAsAPIString(string dateString, bool fullDateTime)
{
DateTime date = DateTime.Parse(dateString);
if (fullDateTime)
dateString = date.ToString("yyyy-M-d HH:mm:ss");
else
dateString = date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0";
return dateString;
}
public static List<T> ReverseList<T>(List<T> inputList)
{
List<T> temp = new();
for (int i = inputList.Count - 1; i >= 0; i--)
{
temp.Add(inputList[i]);
}
return temp;
}
public static string SplitOnCamelCase(string input)
{
Regex r = new(@"
(?<=[A-Z])(?=[A-Z][a-z]) |
(?<=[^A-Z])(?=[A-Z]) |
(?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace);
return r.Replace(input, " ");
}
}