Skip to content

Commit adfed35

Browse files
committed
♻️ refactor: update codebase #2
1 parent 317f90c commit adfed35

9 files changed

Lines changed: 1214 additions & 1247 deletions

File tree

constant.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff 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.
1511
var (
@@ -28,28 +24,6 @@ var (
2824
// Deprecated: Use GetWeekStartDay() and SetWeekStartDay() for thread-safe access.
2925
var 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-
5327
const (
5428
// Time in format 15:04:05,
5529
// e.g., 13:45:30

entry.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@ package timefy
22

33
import "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
//

0 commit comments

Comments
 (0)