Skip to content

Show the UTC weekday in the Timestamp Converter - #23

Open
SakarPaisen wants to merge 1 commit into
github-community-gitam:mainfrom
SakarPaisen:feat/timestamp-utc-weekday-14
Open

SakarPaisen wants to merge 1 commit into
github-community-gitam:mainfrom
SakarPaisen:feat/timestamp-utc-weekday-14

Conversation

@SakarPaisen

Copy link
Copy Markdown
Contributor

What

Closes #14.

convert_timestamp now returns weekday_utc, the English weekday name of the converted UTC date, in both directions.

>>> convert_timestamp("0")
{'unix_seconds': 0.0, 'iso_utc': '1970-01-01T00:00:00Z', 'weekday_utc': 'Thursday'}
>>> convert_timestamp("1970-01-02T00:30:00+01:00", "to_unix")
{'unix_seconds': 84600.0, 'iso_utc': '1970-01-01T23:30:00Z', 'weekday_utc': 'Thursday'}

Scope

  • src/mcp_tools_lab/tools/timestamps.py — a fixed WEEKDAYS tuple indexed by date.weekday(), plus a docstring line.
  • tests/test_timestamps.py — four new tests.
  • docs/tool-guide.md — documents the field and the midnight-crossing example.

The name comes from a fixed list rather than locale formatting, so it does not depend on the machine's language settings. Existing values and error handling are unchanged.

Tests added

  • Known weekdays: epoch "0" → Thursday; "345600" → Monday; "1970-01-04T00:00:00Z" in to_unix → Sunday.
  • Offset crossing midnight: "1970-01-02T00:30:00+01:00" is 1970-01-01T23:30:00Z → Thursday, even though the input's local date is Friday.
  • Negative timestamp: "-0.5" → Wednesday.
  • Both directions agree for the same instant.

Millisecond mode

#6 (millisecond support) has not landed: convert_timestamp still takes only value and direction. There is therefore no second output mode to cover yet; when #6 lands, weekday_utc is already part of the single return statement, so it will apply there as well.

Checks

  • python -m pytest tests/test_timestamps.py -q — 13 passed
  • python -m pytest -q — 66 passed
  • python examples/try_tools.py — runs and shows 'weekday_utc': 'Thursday'
  • python .github/scripts/check_rules.py — Scanned 11 files under src/ for print() and network imports: OK
  • Direct calls for "0", the midnight-crossing offset, and "-0.5", printed and compared with the issue's examples

Python: 3.13 on Windows 11.

(Full disclosure: I used an AI coding assistant for this change, and I reviewed and verified everything submitted here.)

convert_timestamp returns weekday_utc, an English weekday name indexed from a fixed Monday-to-Sunday tuple using the converted UTC date, so neither the input's offset nor the machine's locale changes it. Existing values and error handling are unchanged; millisecond support (github-community-gitam#6) has not landed, so there is no extra mode to cover. Tests use the issue's epoch and midnight-crossing examples plus a negative timestamp.
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.

Show the UTC weekday in Timestamp Converter

1 participant