Skip to content

Fix timezone issues by enforcing UTC for all time operations#244

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-timezone-issue
Open

Fix timezone issues by enforcing UTC for all time operations#244
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-timezone-issue

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Fix timezone issues with time.Now() usage

Based on analysis of the codebase, I've identified and fixed all instances of time.Now() to use UTC timezone to avoid issues during time shifts.

Changes completed:

  • Analyze all time.Now() usages and categorize by type
  • Fix timing/latency measurements in modes.go (17 instances)
  • Fix result tracking in pkg/results/ (5 instances)
  • Fix workload generators in pkg/workloads/ (4 instances)
  • Fix random seed generation in random/random.go (1 instance)
  • Fix main.go startTime initialization (1 instance)
  • Update test files appropriately (4 instances)
  • Write comprehensive tests to validate UTC enforcement
  • Run full test suite to verify changes (all tests pass)
  • Validate with build and manual testing
  • Fix linting error (variable shadowing)
Original prompt

This section details on the original issue you should resolve

<issue_title>Timezone issue</issue_title>
<issue_description>I see that code uses time.Now() everywhere it leads to the problem when you run test during time shift.
It would be better to, at least internally, enforce UTC timezone.

Migrated to Jira: QATOOLS-70

<agent_instructions>suggest fixes for all of those usage of time.Now()</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@dani-tweig Closing this issue as it was moved to Jira. Please continue the thread in https://scylladb.atlassian.net/browse/QATOOLS-70

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Replace all time.Now() calls with time.Now().UTC() to prevent issues during
daylight saving time shifts and other timezone-related changes. This ensures
consistent time operations regardless of the system's local timezone setting.

Changes:
- modes.go: Updated all timing/latency measurements to use UTC
- pkg/results/: Updated result tracking timestamps to use UTC
- pkg/workloads/: Updated workload generators to use UTC for random seeding and time calculations
- random/random.go: Updated global seed generation to use UTC
- main.go: Updated startTime initialization to use UTC
- Test files: Updated to use UTC for consistency
- Added comprehensive timezone tests to verify UTC enforcement

Co-authored-by: fruch <340979+fruch@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix timezone issue by enforcing UTC usage Fix timezone issues by enforcing UTC for all time operations Jan 18, 2026
Copilot AI requested a review from fruch January 18, 2026 09:54
@fruch fruch requested a review from a team January 18, 2026 10:44
@fruch fruch marked this pull request as ready for review January 18, 2026 10:44
@fruch
Copy link
Contributor

fruch commented Jan 18, 2026

The variable 'startTime' in timezone_test.go was shadowing the global
'startTime' variable declared in main.go. Renamed the local variable to
'histogramStartTime' to fix the govet shadow warning.

Co-authored-by: fruch <340979+fruch@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 18, 2026

@copilot

linting is faliing:
...

Fixed in commit 81a2fe8. The issue was a variable shadowing warning - the local variable startTime in the test was shadowing the global startTime variable from main.go. Renamed it to histogramStartTime to resolve the govet shadow warning.

@CodeLieutenant
Copy link
Contributor

@fruch I've already worked on it 2 days ago, haven't finished it, will push it in tomorrow.
Mine implementation is little bit different. I've extracted time.Now() into separate file and created a function around it, so that if we need to change it to some different timezone for some reason it's only in one place, and not scattered like it's now

@fruch
Copy link
Contributor

fruch commented Jan 22, 2026

@fruch I've already worked on it 2 days ago, haven't finished it, will push it in tomorrow. Mine implementation is little bit different. I've extracted time.Now() into separate file and created a function around it, so that if we need to change it to some different timezone for some reason it's only in one place, and not scattered like it's now

it's a basic builtin utility, not sure wrapping it is a better solution.

also if you were working on something, you should state it on the issue (move it in progress by the minimum)

@fruch fruch requested review from CodeLieutenant and removed request for a team and fruch January 22, 2026 14:41
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.

Timezone issue

3 participants

Comments