Skip to content

Commit

Permalink
Pass rc.weekstart to libshared for ISO8601 weeknum parsing if "monday" (
Browse files Browse the repository at this point in the history
#3654)

* libshared: bump for weekstart, epoch defines, eopww fix

mainly those visible changes, and miscellaneous others

see #3623 (weekstart)
see #3651 (epoch limit defines)
see GothenburgBitFactory/libshared#73 (eopww fix)

* Initialize libshared's weekstart from user's rc.weekstart config

This enables use of newer libshared code that can parse week numbers
according to ISO8601 instead of existing code which is always using
Sunday-based weeks.  To get ISO behavior, set rc.weekstart=monday.
Default is still Sunday / old algorithm, as before, since Sunday is in
the hardcoded default rcfile.

Weekstart does not yet fix week-relative shortcuts, which will still
always use Monday.

See #3623 for further details.
  • Loading branch information
smemsh authored Oct 19, 2024
1 parent 7bd3d1b commit 3e20ad6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,11 @@ void Context::staticInitialization() {
Task::regex = Variant::searchUsingRegex = config.getBoolean("regex");
Lexer::dateFormat = Variant::dateFormat = config.get("dateformat");

auto weekStart = Datetime::dayOfWeek(config.get("weekstart"));
if (weekStart != 0 && weekStart != 1)
throw std::string(
"The 'weekstart' configuration variable may only contain 'Sunday' or 'Monday'.");
Datetime::weekstart = weekStart;
Datetime::isoEnabled = config.getBoolean("date.iso");
Datetime::standaloneDateEnabled = false;
Datetime::standaloneTimeEnabled = false;
Expand Down
7 changes: 1 addition & 6 deletions src/commands/CmdCalendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,7 @@ int CmdCalendar::execute(std::string& output) {
std::string CmdCalendar::renderMonths(int firstMonth, int firstYear, const Datetime& today,
std::vector<Task>& all, int monthsPerLine) {
auto& config = Context::getContext().config;

// What day of the week does the user consider the first?
auto weekStart = Datetime::dayOfWeek(config.get("weekstart"));
if (weekStart != 0 && weekStart != 1)
throw std::string(
"The 'weekstart' configuration variable may only contain 'Sunday' or 'Monday'.");
auto weekStart = Datetime::weekstart;

// Build table for the number of months to be displayed.
Table view;
Expand Down
2 changes: 1 addition & 1 deletion src/libshared
Submodule libshared updated 115 files

0 comments on commit 3e20ad6

Please sign in to comment.