Working with Date and Time
Working with date and time can be difficult in any programming language. Go’s standard library offers easy-to-use tools to work with date and time constructs. These may be somewhat different from what many people are used to. For example, there are libraries in different languages that make a distinction between a time
type and a date
type. Go’s standard library only includes a time.Time
type. That might make you feel disoriented when you’re working with Go’s time.
I’d like to think that Go’s treatment of date/time reduces the chances of creating subtle bugs. You see, you have to be really careful and clear about what you mean when you talk about time: are you talking about a point in time or an interval? A date is actually an interval (for instance, 08/01/2024 starts at 08/01/2024T00:00:00 and continues until 08/01/2024T23:59:59) even though usually that is not the intent. A specific date/time value also depends...