Problem
The pipedrive_my_overdue_activities and pipedrive_my_upcoming_activities tools use a UTC-based today() helper for client-side filtering:
function today(): string {
return new Date().toISOString().split("T")[0];
}
This causes incorrect results for users outside UTC:
- Positive offsets (e.g. UTC+12 Auckland): an activity due "yesterday" in user local time won't be flagged as overdue for several hours until UTC catches up
- Negative offsets (e.g. UTC-8 Los Angeles): an activity due "today" in user local time gets flagged as overdue prematurely (once UTC rolls to the next day)
The problem compounds for timed activities, which are returned from the Pipedrive API as UTC timestamps (due_date + due_time combined). A timed activity at 9am tomorrow local could have due_date: "<today UTC>" in the response, so even a user-local-TZ fix to today() alone wouldn't handle it correctly.
Proposed approach
- Fetch
timezone_name from /users/me (IANA name, e.g. Pacific/Auckland), cache alongside the existing current-user info
- Add helpers for:
todayInTZ(tz): today's date in a specific IANA timezone
effectiveDeadline(due_date, due_time, tz): resolves date-only activities (already in user TZ) and timed activities (UTC → local) into a comparable local date / moment
- Rewrite the overdue/upcoming filters to use these
- For
as_user scenarios, use the target user's timezone (from /users entry)
Questions
Handling IANA timezones cleanly in JavaScript is notoriously verbose with stdlib only. Two reasonable implementation paths:
- Stdlib only using
Intl.DateTimeFormat.formatToParts(), no new deps, but several helper functions and some awkwardness
- Add Luxon or similar library (~70KB tree-shakeable, battle-tested) for clean timezone math
Would you prefer to keep the dep footprint minimal, or is a date library acceptable for something this central?
Scope
In scope:
pipedrive_my_overdue_activities, pipedrive_my_upcoming_activities
- Tests covering multiple timezones and both date-only and timed activities
Out of scope:
pipedrive_stale_deals / pipedrive_recently_updated (these pass date filters to Pipedrive's API which handles them in UTC, so the current UTC-based daysAgo is roughly correct)
Willing to pick this up once you've confirmed direction.
Problem
The
pipedrive_my_overdue_activitiesandpipedrive_my_upcoming_activitiestools use a UTC-basedtoday()helper for client-side filtering:This causes incorrect results for users outside UTC:
The problem compounds for timed activities, which are returned from the Pipedrive API as UTC timestamps (
due_date+due_timecombined). A timed activity at 9am tomorrow local could havedue_date: "<today UTC>"in the response, so even a user-local-TZ fix totoday()alone wouldn't handle it correctly.Proposed approach
timezone_namefrom/users/me(IANA name, e.g.Pacific/Auckland), cache alongside the existing current-user infotodayInTZ(tz): today's date in a specific IANA timezoneeffectiveDeadline(due_date, due_time, tz): resolves date-only activities (already in user TZ) and timed activities (UTC → local) into a comparable local date / momentas_userscenarios, use the target user's timezone (from/usersentry)Questions
Handling IANA timezones cleanly in JavaScript is notoriously verbose with stdlib only. Two reasonable implementation paths:
Intl.DateTimeFormat.formatToParts(), no new deps, but several helper functions and some awkwardnessWould you prefer to keep the dep footprint minimal, or is a date library acceptable for something this central?
Scope
In scope:
pipedrive_my_overdue_activities,pipedrive_my_upcoming_activitiesOut of scope:
pipedrive_stale_deals/pipedrive_recently_updated(these pass date filters to Pipedrive's API which handles them in UTC, so the current UTC-baseddaysAgois roughly correct)Willing to pick this up once you've confirmed direction.