Skip to content

Fix macOS (aarch64-darwin) build: replace zoned_time with portable localtime_r/strftime#37

Merged
gfauredev merged 2 commits intomainfrom
copilot/fix-macos-nix-build-aarch64
Mar 14, 2026
Merged

Fix macOS (aarch64-darwin) build: replace zoned_time with portable localtime_r/strftime#37
gfauredev merged 2 commits intomainfrom
copilot/fix-macos-nix-build-aarch64

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

std::chrono::zoned_time and std::chrono::current_zone() are absent from Apple's libc++ on macOS 14, breaking every translation unit that includes Logger.hpp.

Changes

  • include/Logger.hpp: Replace zoned_time-based time() and date() helpers with localtime_r + strftime. Add <ctime> include. Update doc comment (format is now HH:MM:SS, not HH:MM:SS.mmm).
  • test/LoggerTest.cpp: Same substitution in the log-rotation test case that reproduced the date string independently.

Before

static std::string time() {
    return std::format(
        "{:%T}", std::chrono::zoned_time{std::chrono::current_zone(),
                                         std::chrono::system_clock::now()});
}

After

static std::string time() {
    auto now = std::chrono::system_clock::now();
    std::time_t t = std::chrono::system_clock::to_time_t(now);
    std::tm local_tm{};
    localtime_r(&t, &local_tm);
    char buf[9];
    std::strftime(buf, sizeof(buf), "%T", &local_tm);
    return std::string(buf);
}

localtime_r is POSIX-standard and thread-safe, covering both Linux and macOS.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: gfauredev <19304085+gfauredev@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix macOS aarch64-darwin Nix build Fix macOS (aarch64-darwin) build: replace zoned_time with portable localtime_r/strftime Mar 14, 2026
Copilot AI requested a review from gfauredev March 14, 2026 13:20
@gfauredev gfauredev marked this pull request as ready for review March 14, 2026 16:28
@gfauredev gfauredev merged commit cf531ec into main Mar 14, 2026
11 checks passed
@gfauredev gfauredev deleted the copilot/fix-macos-nix-build-aarch64 branch March 14, 2026 16:28
@github-actions
Copy link
Copy Markdown

📊 Coverage Report

Coverage Summary

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
include/GameEngine.hpp              4                 0   100.00%           2                 0   100.00%           7                 0   100.00%           0                 0         -
include/IGameMode.hpp               3                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
include/IMidiInput.hpp              1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
include/ITransport.hpp              1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
include/Logger.hpp                 27                 2    92.59%           7                 0   100.00%          54                 1    98.15%          16                 2    87.50%
include/Message.hpp                11                 0   100.00%           5                 0   100.00%          10                 0   100.00%           2                 0   100.00%
include/Note.hpp                    8                 0   100.00%           2                 0   100.00%           7                 0   100.00%           4                 0   100.00%
include/RtMidiInput.hpp             4                 0   100.00%           4                 0   100.00%           7                 0   100.00%           0                 0         -
include/UdsTransport.hpp            4                 0   100.00%           3                 0   100.00%           8                 0   100.00%           0                 0         -
src/AnswerValidator.cpp            67                 7    89.55%           5                 0   100.00%          99                 7    92.93%          48                12    75.00%
src/ChallengeFactory.cpp           19                 0   100.00%           5                 0   100.00%          58                 0   100.00%          10                 0   100.00%
src/ChordGame.cpp                  53                 0   100.00%           4                 0   100.00%         104                 0   100.00%          40                 1    97.50%
src/GameEngine.cpp                 64                 2    96.88%           7                 0   100.00%         128                 3    97.66%          42                 4    90.48%
src/NoteGame.cpp                   39                 1    97.44%           4                 0   100.00%          76                 0   100.00%          28                 3    89.29%
src/RtMidiInput.cpp                56                 7    87.50%          16                 6    62.50%         136                16    88.24%          32                 7    78.12%
src/UdsTransport.cpp               82                 3    96.34%           8                 0   100.00%         126                12    90.48%          51                 6    88.24%
src/main.cpp                       25                 2    92.00%           3                 0   100.00%          52                10    80.77%          14                 6    57.14%
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                             468                24    94.87%          79                 6    92.41%         876                49    94.41%         287                41    85.71%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants