summaryrefslogtreecommitdiff
path: root/internal/commands
diff options
context:
space:
mode:
authorT <t@tjp.lol>2025-08-04 10:41:08 -0600
committerT <t@tjp.lol>2025-08-04 10:52:51 -0600
commit4c29dfee9be26996ce548e2edf0328422df598d0 (patch)
treebe38e53526f7ddb8e10e9671005b9ecd671a7152 /internal/commands
parent8be5f93f5b2d4b6f438ca84094937a0f7101c59b (diff)
Fix time query parameters to force them to datetime format
Diffstat (limited to 'internal/commands')
-rw-r--r--internal/commands/billable_rate_test.go5
-rw-r--r--internal/commands/import.go8
2 files changed, 8 insertions, 5 deletions
diff --git a/internal/commands/billable_rate_test.go b/internal/commands/billable_rate_test.go
index f9ce621..184d51f 100644
--- a/internal/commands/billable_rate_test.go
+++ b/internal/commands/billable_rate_test.go
@@ -174,8 +174,8 @@ func TestTimeEntryWithTimesCoalescing(t *testing.T) {
// Create time entry with times but no explicit rate - should use project rate
now := time.Now().UTC()
timeEntry, err := q.CreateTimeEntryWithTimes(context.Background(), queries.CreateTimeEntryWithTimesParams{
- StartTime: now,
- EndTime: sql.NullTime{Time: now.Add(time.Hour), Valid: true},
+ StartTime: now.Format(time.DateTime),
+ EndTime: now.Add(time.Hour).Format(time.DateTime),
Description: sql.NullString{String: "Test work", Valid: true},
ClientID: client.ID,
ProjectID: sql.NullInt64{Int64: project.ID, Valid: true},
@@ -222,4 +222,3 @@ func TestTimeEntryCoalescingWithoutProject(t *testing.T) {
t.Errorf("Expected billable_rate 7550, got %v", timeEntry.BillableRate)
}
}
-
diff --git a/internal/commands/import.go b/internal/commands/import.go
index a767923..a1d0d8f 100644
--- a/internal/commands/import.go
+++ b/internal/commands/import.go
@@ -186,9 +186,13 @@ func importSingleEntry(q *queries.Queries, entry clockifyEntry, loc *time.Locati
projectID = sql.NullInt64{Int64: project.ID, Valid: true}
}
+ // Format times as SQLite-compatible strings for the datetime() function
+ startTimeStr := startTime.UTC().Format(time.DateTime)
+ endTimeStr := endTime.UTC().Format(time.DateTime)
+
_, err = q.CreateTimeEntryWithTimes(context.Background(), queries.CreateTimeEntryWithTimesParams{
- StartTime: startTime.UTC(),
- EndTime: sql.NullTime{Time: endTime.UTC(), Valid: true},
+ StartTime: startTimeStr,
+ EndTime: endTimeStr,
Description: sql.NullString{String: entry.Description, Valid: entry.Description != ""},
ClientID: client.ID,
ProjectID: projectID,