Skip to content

Release 1.55.0 to master#596

Open
krystophv wants to merge 30 commits intomasterfrom
release-1.55.0
Open

Release 1.55.0 to master#596
krystophv wants to merge 30 commits intomasterfrom
release-1.55.0

Conversation

@krystophv
Copy link
Member

@krystophv krystophv commented Feb 18, 2026

along side tidepool-org/blip#1873

This pull request introduces improvements to date formatting and reporting period display, particularly for text exports, and enhances robustness in handling device clock drift for pump settings data. It also adds new utilities for chart date formatting and updates related tests to ensure correct behavior.

Date formatting and reporting period improvements:

  • Added getChartDateBoundFormat and CHART_DATE_BOUND_FORMAT utilities to standardize chart/reporting date and time formatting in src/utils/datetime.js, and integrated them into TextUtil for more accurate reporting period display, including support for partial dates and inclusive end dates. [1] [2] [3] [4] [5] [6] [7]
  • Updated the buildDocumentDates method in TextUtil to use the new chart date formatting logic, ensuring correct handling of midnight bounds and time zones.
  • Modified the reporting period display in both Basics and Trends text exports to use the improved date formatting, showing partial dates when appropriate. [1] [2]

Pump settings clock drift handling:

  • Enhanced logic in DataUtil to tolerate up to 15 minutes of device/server clock drift when associating pump settings data with uploads, preventing exclusion of valid settings due to minor time discrepancies.

Testing improvements:

  • Added and updated tests in test/utils/DataUtil.test.js to verify correct selection of pump settings data within the 15-minute drift window, and to ensure exclusion beyond that threshold. [1] [2] [3]
  • Expanded tests in test/utils/text/TextUtil.test.js to cover new date formatting scenarios, including partial dates and inclusive end dates.

henry-tp and others added 30 commits January 26, 2026 10:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
[WEB-4330] - Missing Pump Settings in PDF
[WEB-4384] - Date Range Header lines up with Copy-as-Text
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates text export/reporting period date formatting and improves pump settings association robustness by tolerating limited device/server clock drift, with corresponding test updates.

Changes:

  • Added chart/reporting date bound format utilities and updated TextUtil to use them (including partial-date/time display and inclusive end dates where appropriate).
  • Updated Basics/Trends text exports to opt into partial-date/time reporting period display.
  • Expanded pump settings selection logic to allow up to 15 minutes of clock drift, with new/updated tests.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/datetime.js Adds shared chart date bound format constants/helper.
src/utils/text/TextUtil.js Reworks reporting period formatting using moment-timezone + new helper.
src/utils/basics/data.js Enables partial-date/time reporting period in Basics text export.
src/utils/trends/data.js Enables partial-date/time reporting period in Trends text export.
src/utils/DataUtil.js Adds 15-minute drift tolerance when selecting pumpSettings for latest upload.
test/utils/text/TextUtil.test.js Updates/extends coverage for new reporting period formatting behavior.
test/utils/DataUtil.test.js Adds coverage for pumpSettings selection within/outside drift window.
src/index.js Exposes new datetime utilities via public utils export.
package.json Bumps package version for the release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1483 to 1491
// Clock drift on user's device may cause pumpSettings datum to have LATER timestamp than upload
// datum. The maximum time deviation that the Uploader allows between the user's device and Tidepool
// server time is 15 minutes, so we search up to 15 minutes into the future for the pumpSettings datum
const UPLOADER_TIME_DEVIATION_TOLERANCE = 15 * MS_IN_MIN;

pumpSettingsForUpload = _.filter(
pumpSettingsForUpload,
ps => ps.time <= latestPumpUpload.time
ps => ps.time <= (latestPumpUpload.time + UPLOADER_TIME_DEVIATION_TOLERANCE)
);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clock-drift tolerance is only applied when filtering pumpSettingsForUpload from pumpSettingsDatumsByIdMap, but the later fallback to this.latestDatumByType.pumpSettings still requires candidate.time <= latestPumpUpload.time for non-continuous uploads. This can still exclude a valid pumpSettings datum that’s within the 15-minute tolerance window when the by-id map doesn’t yield a match. Consider reusing the same tolerance check for the fallback path as well (and ideally hoist the tolerance constant so it’s not duplicated).

Copilot uses AI. Check for mistakes.
Comment on lines +187 to +215
export const CHART_DATE_BOUND_FORMAT = {
DATE_AND_TIME: 'MMM D, YYYY (h:mm A)',
DATE_ONLY: 'MMM D, YYYY',
};

/**
* getChartDateBoundFormat
* @param {Object} startDate - a moment time object
* @param {Object} endDate - a moment time object
*
* @return {String} a moment time format (e.g 'MMM D, YYYY')
*/
export function getChartDateBoundFormat(startDate, endDate) {
if (!endDate) return CHART_DATE_BOUND_FORMAT.DATE_ONLY;

const isStartDateMidnight = (startDate?.hours() === 0 && startDate?.minutes() === 0) ||
(startDate?.hours() === 23 && startDate?.minutes() >= 59);

const isEndDateMidnight = (endDate?.hours() === 0 && endDate?.minutes() === 0) ||
(endDate?.hours() === 23 && endDate?.minutes() >= 59);

const isMatchingDateBounds = isStartDateMidnight && isEndDateMidnight;

if (!isMatchingDateBounds) {
return CHART_DATE_BOUND_FORMAT.DATE_AND_TIME;
}

return CHART_DATE_BOUND_FORMAT.DATE_ONLY;
}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/utils/datetime.js has an in-file guideline to keep utilities organized alphabetically, but the newly added CHART_DATE_BOUND_FORMAT/getChartDateBoundFormat appear inserted here after formatDateRange, which breaks that convention. Please relocate these exports to match the file’s stated ordering so future diffs remain easy to scan.

Copilot uses AI. Check for mistakes.
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.

4 participants