Skip to content

Commit

Permalink
options/ansi: Implement %E in strftime
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke committed Jun 27, 2024
1 parent c7d364a commit 18bd15e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions options/ansi/generic/time-stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ size_t strftime(char *__restrict dest, size_t max_size,
auto c = format;
auto p = dest;
[[maybe_unused]] bool use_alternative_symbols = false;
[[maybe_unused]] bool use_alternative_era_format = false;

while(*c) {
int chunk;
Expand Down Expand Up @@ -124,6 +125,21 @@ size_t strftime(char *__restrict dest, size_t max_size,
c++;
continue;
}
} else if(*(c + 1) == 'E') {
std::array<char, 6> valid{{'c', 'C', 'x', 'X', 'y', 'Y'}};
auto next = *(c + 2);
if(std::find(valid.begin(), valid.end(), next) != valid.end()) {
use_alternative_era_format = true;
c++;
} else {
*p = '%';
p++;
c++;
*p = 'E';
p++;
c++;
continue;
}
}

switch(*++c) {
Expand Down

0 comments on commit 18bd15e

Please sign in to comment.