feat(dates): accept time-of-day on --due-date and --start-date#77
Merged
Merged
Conversation
Previously, --due-date and --start-date only accepted YYYY-MM-DD and always
wrote the task with due_date_time/start_date_time = false. This made it
impossible to set tasks at a specific time of day from the CLI, even though
the ClickUp API natively supports it.
This extends parseDueDate to accept three input shapes, backward compatible:
- YYYY-MM-DD (existing behavior; date-only)
- YYYY-MM-DDTHH:MM[:SS] (wall clock in user's ClickUp timezone)
- YYYY-MM-DDTHH:MM[:SS]±HH:MM | Z (absolute ISO 8601 instant)
When the input includes a time component, the payload's due_date_time /
start_date_time is set to true, so ClickUp displays the task with time and
the Google Calendar integration emits a timed event rather than an all-day one.
Changes:
- parseDueDate now returns { ms, hasTime } instead of number; callers
(update, create, bulk, goals) use the new shape.
- Reuses the existing IANA-timezone offset technique, generalized from
midnight-only to arbitrary wall-clock times.
- Range-checks HH/MM/SS to reject e.g. "T25:00".
- Help text on --due-date / --start-date updated in update + create.
- 9 new unit tests covering date-only, local datetime, datetime+tz, full
ISO with Z, full ISO with explicit offset, and malformed inputs.
Tests: 70/70 update tests pass; full suite 1107 passing with 4 pre-existing
failures (config/interactive/completion-doc-sync) untouched by this change.
Owner
|
Thanks for this — clean refactor with excellent test coverage. The Merged and shipping in v1.28.0 with docs updates for the new formats. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
--due-dateand--start-datecurrently accept onlyYYYY-MM-DDand always writedue_date_time/start_date_timeasfalse. That makes it impossible to set tasks at a specific time of day from the CLI, even though the ClickUp REST API supports it natively.This PR extends
parseDueDateto accept three input shapes, fully backward compatible:*_date_time2025-03-15false2025-03-15T14:30(orT14:30:00)true2025-03-15T14:30:00+08:00or...ZtrueWhen a time component is present, the API payload sets
due_date_time/start_date_timetotrue, so ClickUp displays the task with time-of-day and the Google Calendar integration emits a timed event instead of an all-day event.Why
This is the gap that triggered the work: planning the day with hourly time blocks is impossible from
cuptoday, because every task lands on the calendar as an all-day event. Users have to fall back to the ClickUp UI or hit the REST API directly. With this patch,cup create -n 'Deep work' --due-date 2025-03-15T16:00andcup update <id> --start-date 2025-03-15T14:30 --due-date 2025-03-15T16:00work end to end and the events appear at the right time on the calendar.Implementation notes
parseDueDate(value, timezone)now returns{ ms: number; hasTime: boolean }instead ofnumber. Callers (update,create,bulk,goals) destructure and propagatehasTimetodue_date_time/start_date_time.dateToTimezoneMsis generalised to arbitrary wall-clock times viawallClockToTimezoneMs. The old function is removed since it was a special case of the new one (hour=minute=second=0).HH/MM/SSreject inputs likeT25:00cleanly.--due-date/--start-dateupdated for bothcreateandupdate.Tests
tests/unit/commands/update.test.tscovering date-only, local datetime, datetime + IANA tz (Australia/Perth), full ISO withZ, full ISO with+08:00, and malformed inputs (out-of-range time, missing minutes).buildUpdatePayloadtests confirmingdue_date_time=true/start_date_time=trueare emitted when a time component is present.config.test.ts > respects XDG_CONFIG_HOME,interactive.test.ts > showDetailsAndOpen, two completion-doc-sync tests) are pre-existing onmainand unrelated to this change — verified by stashing the patch and re-running.Compatibility
Backward compatible at the CLI surface: every existing
YYYY-MM-DDinvocation produces the same payload it did before (*_date_time: false). Only callers that opt into the new time-of-day syntax see the new behaviour.The
parseDueDatefunction signature change (now{ ms, hasTime }) is internal — it's not re-exported as a public API. All in-repo callers are updated in the same PR.