public static void Main()
var dto = new TimeCardImportStandardDto()
DateTime startTime = DateTime.SpecifyKind(new DateTime(2022, 3, 12, 18, 55, 00), DateTimeKind.Unspecified);
var expectedEndDate = TimeZoneInfo.Local.DisplayName != TimeZoneInfo.Utc.DisplayName && startTime.Kind == DateTimeKind.Utc ? new DateTime(2022, 3, 13, 2, 14, 48) : new DateTime(2022, 3, 13, 3, 14, 48);
Console.WriteLine($"expectedEndDate: {expectedEndDate}");
dto.TryParseEndDate(startTime, out endDate);
Console.WriteLine($"test: {endDate == expectedEndDate}");
Console.WriteLine("----------------------------------------------------");
startTime = DateTime.SpecifyKind(new DateTime(2022, 3, 12, 18, 55, 00), DateTimeKind.Utc);
expectedEndDate = TimeZoneInfo.Local.DisplayName != TimeZoneInfo.Utc.DisplayName && startTime.Kind == DateTimeKind.Utc ? new DateTime(2022, 3, 13, 2, 14, 48) : new DateTime(2022, 3, 13, 3, 14, 48);
Console.WriteLine($"expectedEndDate: {expectedEndDate}");
dto.TryParseEndDate(startTime, out endDate);
Console.WriteLine($"test: {endDate == expectedEndDate}");
Console.WriteLine("----------------------------------------------------");
startTime = DateTime.SpecifyKind(new DateTime(2022, 3, 12, 18, 55, 00), DateTimeKind.Local);
expectedEndDate = TimeZoneInfo.Local.DisplayName != TimeZoneInfo.Utc.DisplayName && startTime.Kind == DateTimeKind.Utc ? new DateTime(2022, 3, 13, 2, 14, 48) : new DateTime(2022, 3, 13, 3, 14, 48);
Console.WriteLine($"expectedEndDate: {expectedEndDate}");
dto.TryParseEndDate(startTime, out endDate);
Console.WriteLine($"test: {endDate == expectedEndDate}");
public class TimeCardImportStandardDto
public string Hours { get; set; }
public static class DateTimeExtensions
public static bool TryParseEndDate(this TimeCardImportStandardDto dto, DateTime startDate, out DateTime endDate)
var hoursParsed = float.TryParse(dto.Hours?.Trim(), out float hours);
var minutesToAdd = Math.Round(hours * 60.00, 5);
endDate = startDate.ToUniversalTime().AddMinutes(minutesToAdd);
endDate = DateTime.SpecifyKind(startDate.Kind == DateTimeKind.Utc ? endDate : endDate.ToLocalTime(), startDate.Kind);
Console.WriteLine($"endDate {endDate}");