File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,10 +6,6 @@ import (
66 "time"
77)
88
9- type TimeRFC string
10- type TimeFormatRFC string
11- type ZoneRFC string
12-
139// weekStartDay holds the default week start day, protected by weekStartDayMu.
1410// Default is Sunday. Use GetWeekStartDay() and SetWeekStartDay() for safe access.
1511var (
2824// Deprecated: Use GetWeekStartDay() and SetWeekStartDay() for thread-safe access.
2925var WeekStartDay = time .Sunday
3026
31- // GetWeekStartDay returns the current default week start day in a thread-safe manner.
32- func GetWeekStartDay () time.Weekday {
33- weekStartDayMu .RLock ()
34- defer weekStartDayMu .RUnlock ()
35- return weekStartDay
36- }
37-
38- // SetWeekStartDay sets the default week start day in a thread-safe manner.
39- //
40- // Note: This function also updates the deprecated WeekStartDay variable for
41- // backward compatibility. However, direct reads from WeekStartDay are not
42- // protected by the mutex. Use GetWeekStartDay() for thread-safe reads.
43- func SetWeekStartDay (day time.Weekday ) {
44- weekStartDayMu .Lock ()
45- defer weekStartDayMu .Unlock ()
46- weekStartDay = day
47- // Update deprecated variable for backward compatibility.
48- // This is intentionally done within the mutex to maintain consistency,
49- // though direct reads of WeekStartDay are still not thread-safe.
50- WeekStartDay = day
51- }
52-
5327const (
5428 // Time in format 15:04:05,
5529 // e.g., 13:45:30
Original file line number Diff line number Diff line change @@ -2,6 +2,28 @@ package timefy
22
33import "time"
44
5+ // GetWeekStartDay returns the current default week start day in a thread-safe manner.
6+ func GetWeekStartDay () time.Weekday {
7+ weekStartDayMu .RLock ()
8+ defer weekStartDayMu .RUnlock ()
9+ return weekStartDay
10+ }
11+
12+ // SetWeekStartDay sets the default week start day in a thread-safe manner.
13+ //
14+ // Note: This function also updates the deprecated WeekStartDay variable for
15+ // backward compatibility. However, direct reads from WeekStartDay are not
16+ // protected by the mutex. Use GetWeekStartDay() for thread-safe reads.
17+ func SetWeekStartDay (day time.Weekday ) {
18+ weekStartDayMu .Lock ()
19+ defer weekStartDayMu .Unlock ()
20+ weekStartDay = day
21+ // Update deprecated variable for backward compatibility.
22+ // This is intentionally done within the mutex to maintain consistency,
23+ // though direct reads of WeekStartDay are still not thread-safe.
24+ WeekStartDay = day
25+ }
26+
527// BeginOfDay takes a time value `v` and returns a new time.Time object
628// representing the beginning of the day for that date.
729//
You can’t perform that action at this time.
0 commit comments