Export and Import Services
ExportService
Protocol
protocol ExportService {
func exportToCSV(
records: [TimeRecord],
tags: [Tag],
options: ExportOptions
) -> Data
} CSV Format
Date,Start Time,End Time,Duration,Tag,Comment
2024-01-15,09:30,11:45,2:15,Work,Working on feature X Export Options
- Date range filtering
- Tag filtering
- Include/exclude untagged
- Include/exclude running timers
- Column selection
Implementation
DefaultExportService in Shared/Sources/MinutaShared/Services/ExportService.swift
ImportService
Protocol
protocol ImportService: Sendable {
func parseHEYCSV(_ content: String, existingTags: [Tag]) -> (records: [ParsedRecord], newTags: [Tag])
} HEY CSV Format
Start,End,Duration,Category,Notes
2024-01-15 09:30,2024-01-15 11:45,2:15,Work,Working on feature X - Dates:
YYYY-MM-DD HH:mm - Duration is ignored (calculated from start/end)
- Category maps to tag name
- Notes maps to comment
ParsedRecord
struct ParsedRecord: Sendable {
let startTime: Date
let endTime: Date
let categoryName: String?
let notes: String?
} Import Flow
- Parse CSV to get
ParsedRecordarray and new tags - Create new tags (auto-assigned random colors from ColorPalette)
- Build tag name -> UUID lookup
- Create TimeRecord for each ParsedRecord with resolved tagId
- Save records via TimeTrackingService
Implementation
HEYImportService in Shared/Sources/MinutaShared/Services/ImportService.swift
Uses CSVParser utility for proper field parsing (handles quoted fields, embedded commas).
UI Integration
Export
- HistorySection uses
fileExportermodifier for save panel - ShareLink for system share sheet
- Generates CSV inline using DurationFormatter and CSVParser
Import
- SettingsSheet uses
fileImportermodifier - Processes file with HEYImportService
- Shows success/error message
Related
Models
- 202-time-record - Source data for export
- 201-tag - Tag names and colors
- 203-export-options - Export configuration
Services
- 301-file-storage - Data retrieval
- 303-time-tracking - Record saving after import
- 306-report - Visual report generation (PDF/SVG/PNG)
UI
- 411-share-export-sheet - Export format selection
- 407-history-section - Export button location
- 405-settings-sheet - Import from HEY