CI / Build and test (push) Successful in 12m32s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 19s
Release / Build, test and publish (push) Successful in 17m13s
CI / PostgreSQL 16 integration (push) Successful in 9m1s
CI / PostgreSQL 17 integration (push) Successful in 9m30s
CI / Docker image (push) Successful in 49s
Release / Server image (push) Successful in 1m49s
The Windows hands-on test of v1.1.0 on the development PC (#70). - The App suite runs whole on Windows again. Five stale screen smoke tests are brought up to date. - The Reorganize capture gives the sample sidecars. - Forget fits in the Bulgarian certificate rows. - The job log shows local time. It stays UTC on disk, and lines are dated backwards from the job's end. - The Jobs and Server › Jobs Type column takes a 1* share (90–170 px). - Builds without a tag say 1.1.1. Closes #70 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
41 lines
2.1 KiB
C#
41 lines
2.1 KiB
C#
using System.Globalization;
|
|
|
|
namespace Chronos.App.Jobs;
|
|
|
|
/// <summary>
|
|
/// The job log stores each line's time of day in UTC (<c>"12:35:04 Copying…"</c>), the same on the server and the desktop.
|
|
/// The Jobs table shows its times in local time, so the log's are shown in local time too (#70).
|
|
/// </summary>
|
|
public static class JobLogTimes
|
|
{
|
|
/// <summary>
|
|
/// <paramref name="tail"/> with each leading <c>HH:mm:ss</c> turned from UTC into <paramref name="zone"/>'s time.
|
|
/// The log keeps no dates, so they are worked out backwards from <paramref name="reference"/> (when the job finished, or
|
|
/// now): each line is the latest instant at or before the line after it, so a run that goes past midnight UTC, or lasts
|
|
/// days, dates its lines right and a daylight-saving change in between converts each side with its own offset. A pause
|
|
/// of a day or more between two lines cannot be seen, and those lines keep the later day's date. Lines without a time
|
|
/// stay as they are.
|
|
/// </summary>
|
|
public static string ToLocal(string tail, DateTimeOffset reference, TimeZoneInfo zone)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(tail);
|
|
ArgumentNullException.ThrowIfNull(zone);
|
|
if (tail.Length == 0) return tail;
|
|
// A minute of slack: the reference may be read a little before the last line's clock (another machine's).
|
|
var next = reference.UtcDateTime.AddMinutes(1);
|
|
var lines = tail.Split('\n');
|
|
for (var i = lines.Length - 1; i >= 0; i--)
|
|
{
|
|
var line = lines[i];
|
|
if (line.Length < 9 || line[8] != ' ' ||
|
|
!TimeSpan.TryParseExact(line.AsSpan(0, 8), @"hh\:mm\:ss", CultureInfo.InvariantCulture, out var time)) continue;
|
|
var utc = DateTime.SpecifyKind(next.Date + time, DateTimeKind.Utc);
|
|
if (utc > next) utc = utc.AddDays(-1);
|
|
next = utc;
|
|
var local = TimeZoneInfo.ConvertTimeFromUtc(utc, zone);
|
|
lines[i] = local.ToString("HH:mm:ss", CultureInfo.InvariantCulture) + line[8..];
|
|
}
|
|
return string.Join('\n', lines);
|
|
}
|
|
}
|