The SDK reaches internal/datetime through settings validation, and that package had only a cgo strftime implementation, so statically linked Tentacle packages could not build. Split the locale-aware cgo formatter into its own file and add a C-locale fallback for builds without cgo. The reader itself still uses the cgo implementation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
812 B
Go
29 lines
812 B
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
//go:build !cgo
|
|
|
|
package datetime
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestFormatFallbackMatchesCLocale(t *testing.T) {
|
|
now := time.Date(2026, time.March, 5, 7, 4, 9, 0, time.UTC)
|
|
for spec, want := range map[string]string{
|
|
"%I:%M %p": "07:04 AM", "%H:%M:%S": "07:04:09", "%X": "07:04:09", "%x": "03/05/26",
|
|
"%A, %-d %B, %Y": "Thursday, 5 March, 2026", "%a, %b %-d": "Thu, Mar 5", "%d/%m/%Y": "05/03/2026",
|
|
"%H hours and %M minutes": "07 hours and 04 minutes", "100%%": "100%",
|
|
} {
|
|
if got := format(now, spec); got != want {
|
|
t.Fatalf("%q = %q, want %q", spec, got, want)
|
|
}
|
|
}
|
|
if !ValidTime("24-hour") || !ValidDate("full-mdy") {
|
|
t.Fatal("validation changed without cgo")
|
|
}
|
|
}
|