Documentation ¶
Overview ¶
Package datepb provides utilities for googleapis/types/date.Date conversion.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Interval ¶
Interval returns a start and end time.Time for the given period in UTC. The precision of the period is determined by the populated fields. start is always at 00:00 on the beginning of the period. end is the period increased by 1, minus 1ns. For example:
- if day is non-zero the period starts at 00:00 and ends 1ns before end of day.
- if day is zero and month is non-zero the period starts on the first day 00:00 and ends 1ns before the end of the last day of the month.
- if day and month are zero, the period starts on 1st of January 00:00 and ends on 31st of December 23:59:00
Example (Day) ¶
start, end := Interval(&date.Date{ Year: 1986, Month: 3, Day: 25, }) fmt.Println(start, end)
Output: 1986-03-25 00:00:00 +0000 UTC 1986-03-25 23:59:59.999999999 +0000 UTC
Example (Month) ¶
start, end := Interval(&date.Date{ Year: 1986, Month: 3, }) fmt.Println(start, end)
Output: 1986-03-01 00:00:00 +0000 UTC 1986-03-31 23:59:59.999999999 +0000 UTC
Example (Year) ¶
start, end := Interval(&date.Date{ Year: 1986, }) fmt.Println(start, end)
Output: 1986-01-01 00:00:00 +0000 UTC 1986-12-31 23:59:59.999999999 +0000 UTC
func Time ¶
Time converts a googleapis/type/date.Date to a standard time.Time in UTC timezone. A date can represent:
- a full year when month and day are empty. The time will be 1st of january 00:00 UTC in the given year.
- a full month when day is empty.
- an exact date with year, month and day.
Overlowing or negative values are normalized by Go's time.Date() function.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.