CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
67 lines
3.3 KiB
C#
67 lines
3.3 KiB
C#
using Chronos.Core.Localization;
|
|
|
|
namespace Chronos.App.Infrastructure;
|
|
|
|
/// <summary>Culture-aware number, size and duration formatting for the UI.</summary>
|
|
public static class Formatting
|
|
{
|
|
/// <summary>Localized "{0} KB" formats from bytes to petabytes (BRIEF §16: sizes follow the language, "96,2 Go").</summary>
|
|
private static readonly string[] ByteUnits = ["Common.Size.B", "Common.Size.KB", "Common.Size.MB", "Common.Size.GB", "Common.Size.TB", "Common.Size.PB"];
|
|
|
|
/// <summary>1,536 → "1.5 KB" (decimal units, as Explorer shows for drives).</summary>
|
|
public static string Bytes(long bytes)
|
|
{
|
|
double value = bytes;
|
|
var unit = 0;
|
|
while (value >= 1000 && unit < ByteUnits.Length - 1)
|
|
{
|
|
value /= 1000;
|
|
unit++;
|
|
}
|
|
var format = unit == 0 || value >= 100 ? "0" : "0.#";
|
|
return Loc.L(ByteUnits[unit], value.ToString(format, Loc.Culture));
|
|
}
|
|
|
|
public static string Count(long n) => n.ToString("N0", Loc.Culture);
|
|
|
|
/// <summary>Compact duration: "2 h 00 m", "5 min", "40 s".</summary>
|
|
public static string Duration(TimeSpan t)
|
|
{
|
|
if (t < TimeSpan.Zero) t = TimeSpan.Zero;
|
|
if (t.TotalHours >= 24) return Loc.L("Common.Duration.Days", (int)t.TotalDays, t.Hours);
|
|
if (t.TotalHours >= 1) return Loc.L("Common.Duration.Hours", (int)t.TotalHours, t.Minutes.ToString("00", Loc.Culture));
|
|
if (t.TotalMinutes >= 1) return Loc.L("Common.Duration.Minutes", (int)Math.Round(t.TotalMinutes));
|
|
return Loc.L("Common.Duration.Seconds", (int)Math.Round(t.TotalSeconds));
|
|
}
|
|
|
|
/// <summary>Clock-style elapsed time for finished jobs: "2:41", "1:02:41".</summary>
|
|
public static string Elapsed(TimeSpan t)
|
|
{
|
|
if (t < TimeSpan.Zero) t = TimeSpan.Zero;
|
|
return t.TotalHours >= 1
|
|
? ((int)t.TotalHours).ToString(Loc.Culture) + ":" + t.Minutes.ToString("00", Loc.Culture) + ":" + t.Seconds.ToString("00", Loc.Culture)
|
|
: ((int)t.TotalMinutes).ToString(Loc.Culture) + ":" + t.Seconds.ToString("00", Loc.Culture);
|
|
}
|
|
|
|
/// <summary>0.62 → "62 %".</summary>
|
|
public static string Percent(double fraction) => Loc.L("Common.Percent", Math.Round(Math.Clamp(fraction, 0, 1) * 100).ToString("0", Loc.Culture));
|
|
|
|
/// <summary>Items per second with one decimal below 100: "11.3", "118".</summary>
|
|
public static string Rate(double perSecond) => perSecond.ToString(perSecond < 100 ? "0.#" : "N0", Loc.Culture);
|
|
|
|
/// <summary>Local time of day in the culture's short format ("09:12").</summary>
|
|
public static string TimeOfDay(DateTimeOffset at) => at.ToLocalTime().ToString("t", Loc.Culture);
|
|
|
|
/// <summary>Calendar date in the culture's short format.</summary>
|
|
public static string Date(DateTimeOffset at) => at.ToLocalTime().ToString("d", Loc.Culture);
|
|
|
|
/// <summary>Camera wall-clock date in the culture's short format.</summary>
|
|
public static string Date(DateTime wallClock) => wallClock.ToString("d", Loc.Culture);
|
|
|
|
/// <summary>
|
|
/// A path, address or fingerprint kept left to right inside right-to-left text (a Unicode left-to-right embedding),
|
|
/// so its separators and digits stay in place; it reads unchanged in left-to-right languages.
|
|
/// </summary>
|
|
public static string LeftToRight(string text) => "\u202A" + text + "\u202C";
|
|
}
|