Add date_format config key for csv command
- Add get_date_format() to config.py: reads [csv] date_format, returns None when absent (falls back to the default %d/%m/%y) - _cmd_csv applies the format to both single-day and weekly date strings - Add 3 tests for get_date_format in TestGetters - Update timesheets.example.toml and README with [csv] date_format key
This commit is contained in:
parent
0204accd05
commit
8b6f0b24e2
5 changed files with 29 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ import pytest
|
|||
from timesheets.config import (
|
||||
DEFAULT_CONFIG_FILENAME,
|
||||
find_default_config,
|
||||
get_date_format,
|
||||
get_map_path,
|
||||
get_token,
|
||||
load_config,
|
||||
|
|
@ -86,3 +87,12 @@ class TestGetters:
|
|||
|
||||
def test_get_map_path_missing_key(self):
|
||||
assert get_map_path({"projects": {}}) is None
|
||||
|
||||
def test_get_date_format_present(self):
|
||||
assert get_date_format({"csv": {"date_format": "%Y-%m-%d"}}) == "%Y-%m-%d"
|
||||
|
||||
def test_get_date_format_missing_section(self):
|
||||
assert get_date_format({}) is None
|
||||
|
||||
def test_get_date_format_missing_key(self):
|
||||
assert get_date_format({"csv": {}}) is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue