display local datetimes in the Job Scheduler (using time zones)

This commit is contained in:
sbwalker
2025-05-13 11:29:26 -04:00
parent 9f18c460d8
commit 139793f3c0
3 changed files with 39 additions and 10 deletions

View File

@ -487,6 +487,35 @@ namespace Oqtane.Modules
return content;
}
// date methods
public DateTime? UtcToLocal(DateTime? datetime)
{
TimeZoneInfo timezone = null;
if (PageState.User != null && !string.IsNullOrEmpty(PageState.User.TimeZoneId))
{
timezone = TimeZoneInfo.FindSystemTimeZoneById(PageState.User.TimeZoneId);
}
else if (!string.IsNullOrEmpty(PageState.Site.TimeZoneId))
{
timezone = TimeZoneInfo.FindSystemTimeZoneById(PageState.Site.TimeZoneId);
}
return Utilities.UtcAsLocalDateTime(datetime, timezone);
}
public DateTime? LocalToUtc(DateTime? datetime)
{
TimeZoneInfo timezone = null;
if (PageState.User != null && !string.IsNullOrEmpty(PageState.User.TimeZoneId))
{
timezone = TimeZoneInfo.FindSystemTimeZoneById(PageState.User.TimeZoneId);
}
else if (!string.IsNullOrEmpty(PageState.Site.TimeZoneId))
{
timezone = TimeZoneInfo.FindSystemTimeZoneById(PageState.Site.TimeZoneId);
}
return Utilities.LocalDateAndTimeAsUtc(datetime, timezone);
}
// logging methods
public async Task Log(Alias alias, LogLevel level, string function, Exception exception, string message, params object[] args)
{