pub struct Workday {
pub id: i32,
pub date: NaiveDate,
pub start: NaiveDateTime,
pub end: Option<NaiveDateTime>,
}Expand description
Represents a complete workday record with temporal boundaries.
A workday encapsulates a single day’s work session with start and end times, providing the fundamental unit for time tracking and productivity analysis. Each workday corresponds to one calendar date and contains the temporal boundaries of work activity for that day.
§Time Representation
All timestamps use NaiveDateTime to represent local timezone times
consistently across the application. This approach avoids timezone
complexity while maintaining accuracy for user-centric time tracking.
§Completion States
- Active Session:
endisNone, indicating ongoing work - Completed Session:
endisSome(timestamp), work session finished - Historical Record: Both start and end times available for analysis
Fields§
§id: i32Database-assigned unique identifier.
Used for internal database operations and referential integrity. Automatically assigned when the workday is created.
date: NaiveDateCalendar date for this work session.
Each date can have only one workday record, enforced by database constraints. Represents the calendar day when work was performed, independent of the actual start/end times which may span midnight.
start: NaiveDateTimeTimestamp when work session began.
Records the exact moment work started for this date, using local timezone for consistency. This timestamp is always required and serves as the foundation for work duration calculations.
end: Option<NaiveDateTime>Timestamp when work session ended, if completed.
None indicates an active/ongoing work session that hasn’t been
completed yet. Some(timestamp) indicates a finished work session
with the exact completion time for duration calculations.