Grokking Advanced Go
Vote

0% completed

​

Time Pitfalls

In a year whose February has 28 days, one month after January 31 is March 3, according to the arithmetic of the time package. Thirty days after the same date is March 2. A monthly order subscription that started on January 31 therefore skips February entirely, unless the code handles this case.

Output:

Jan 31 Mar 3 Mar 2

The package is doing what its documentation says, and each result has a precise reason. The same is true of the other surprises in time, and many of them come from one fact: a time.Time holds more than a date and a clock reading

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content