| 1 | // Copyright 2016 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // Package civil implements types for civil time, a time-zone-independent |
| 16 | // representation of time that follows the rules of the proleptic |
| 17 | // Gregorian calendar with exactly 24-hour days, 60-minute hours, and 60-second |
| 18 | // minutes. |
| 19 | // |
| 20 | // Because they lack location information, these types do not represent unique |
| 21 | // moments or intervals of time. Use time.Time for that purpose. |
| 22 | package civilscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ |
| 23 | |
| 24 | import ( |
| 25 | "database/sql/driverscip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/" |
| 26 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 27 | "timescip-go gomod github.com/golang/go/src go1.24.0 time/" |
| 28 | ) |
| 29 | |
| 30 | // A Date represents a date (year, month, day). |
| 31 | // |
| 32 | // This type does not include location information, and therefore does not |
| 33 | // describe a unique 24-hour timespan. |
| 34 | type Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# struct { |
| 35 | Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year. int // Year (e.g., 2014). |
| 36 | Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month. timescip-go gomod github.com/golang/go/src go1.24.0 time/.Monthscip-go gomod github.com/golang/go/src go1.24.0 time/Month# // Month of the year (January = 1, ...). |
| 37 | Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day. int // Day of the month, starting at 1. |
| 38 | } |
| 39 | |
| 40 | // DateOf returns the Date in which a time occurs in that time's location. |
| 41 | func DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(t timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#) Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# { |
| 42 | var d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# |
| 43 | d.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year., d.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month., d.Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day. = t.Datescip-go gomod github.com/golang/go/src go1.24.0 time/Time#Date().() |
| 44 | return d |
| 45 | } |
| 46 | |
| 47 | // ParseDate parses a string in RFC3339 full-date format and returns the date value it represents. |
| 48 | func ParseDatescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDate().(s string) (Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#, error) { |
| 49 | t, err := timescip-go gomod github.com/golang/go/src go1.24.0 time/.Parsescip-go gomod github.com/golang/go/src go1.24.0 time/Parse().("2006-01-02", s) |
| 50 | if err != nil { |
| 51 | return Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#{}, err |
| 52 | } |
| 53 | return DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(t), nil |
| 54 | } |
| 55 | |
| 56 | // String returns the date in RFC3339 full-date format. |
| 57 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#String().() string { |
| 58 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%04d-%02d-%02d", d.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year., d.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month., d.Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day.) |
| 59 | } |
| 60 | |
| 61 | // IsValid reports whether the date is valid. |
| 62 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) IsValidscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#IsValid().() bool { |
| 63 | return DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(d.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.)) == d |
| 64 | } |
| 65 | |
| 66 | // In returns the time corresponding to time 00:00:00 of the date in the location. |
| 67 | // |
| 68 | // In is always consistent with time.Date, even when time.Date returns a time |
| 69 | // on a different day. For example, if loc is America/Indiana/Vincennes, then both |
| 70 | // |
| 71 | // time.Date(1955, time.May, 1, 0, 0, 0, 0, loc) |
| 72 | // |
| 73 | // and |
| 74 | // |
| 75 | // civil.Date{Year: 1955, Month: time.May, Day: 1}.In(loc) |
| 76 | // |
| 77 | // return 23:00:00 on April 30, 1955. |
| 78 | // |
| 79 | // In panics if loc is nil. |
| 80 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(loc *timescip-go gomod github.com/golang/go/src go1.24.0 time/.Locationscip-go gomod github.com/golang/go/src go1.24.0 time/Location#) timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time# { |
| 81 | return timescip-go gomod github.com/golang/go/src go1.24.0 time/.Datescip-go gomod github.com/golang/go/src go1.24.0 time/Date().(d.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year., d.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month., d.Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day., 0, 0, 0, 0, loc) |
| 82 | } |
| 83 | |
| 84 | // AddDays returns the date that is n days in the future. |
| 85 | // n can also be negative to go into the past. |
| 86 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) AddDaysscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#AddDays().(n int) Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# { |
| 87 | return DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(d.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).AddDatescip-go gomod github.com/golang/go/src go1.24.0 time/Time#AddDate().(0, 0, n)) |
| 88 | } |
| 89 | |
| 90 | // AddMonths returns the date that is n months in the future. |
| 91 | // n can also be negative to go into the past. |
| 92 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) AddMonthsscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#AddMonths().(n int) Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# { |
| 93 | return DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(d.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).AddDatescip-go gomod github.com/golang/go/src go1.24.0 time/Time#AddDate().(0, n, 0)) |
| 94 | } |
| 95 | |
| 96 | // AddYears returns the date that is n years in the future. |
| 97 | // n can also be negative to go into the past. |
| 98 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) AddYearsscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#AddYears().(n int) Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# { |
| 99 | return DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(d.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).AddDatescip-go gomod github.com/golang/go/src go1.24.0 time/Time#AddDate().(n, 0, 0)) |
| 100 | } |
| 101 | |
| 102 | // DaysSince returns the signed number of days between the date and s, not including the end day. |
| 103 | // This is the inverse operation to AddDays. |
| 104 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) DaysSincescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#DaysSince().(s Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) (days int) { |
| 105 | // We convert to Unix time so we do not have to worry about leap seconds: |
| 106 | // Unix time increases by exactly 86400 seconds per day. |
| 107 | deltaUnix := d.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).Unixscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Unix().() - s.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).Unixscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Unix().() |
| 108 | return int(deltaUnix / 86400) |
| 109 | } |
| 110 | |
| 111 | // Before reports whether d occurs before d2. |
| 112 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Before().(d2 Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) bool { |
| 113 | if d.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year. != d2.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year. { |
| 114 | return d.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year. < d2.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year. |
| 115 | } |
| 116 | if d.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month. != d2.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month. { |
| 117 | return d.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month. < d2.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month. |
| 118 | } |
| 119 | return d.Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day. < d2.Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day. |
| 120 | } |
| 121 | |
| 122 | // After reports whether d occurs after d2. |
| 123 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Afterscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#After().(d2 Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) bool { |
| 124 | return d2.Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Before().(d) |
| 125 | } |
| 126 | |
| 127 | // Compare compares d and d2. If d is before d2, it returns -1; |
| 128 | // if d is after d2, it returns +1; otherwise it returns 0. |
| 129 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Comparescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Compare().(d2 Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) int { |
| 130 | if d.Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Before().(d2) { |
| 131 | return -1 |
| 132 | } else if d.Afterscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#After().(d2) { |
| 133 | return +1 |
| 134 | } |
| 135 | return 0 |
| 136 | } |
| 137 | |
| 138 | // IsZero reports whether date fields are set to their default value. |
| 139 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) IsZeroscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#IsZero().() bool { |
| 140 | return (d.Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year. == 0) && (int(d.Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month.) == 0) && (d.Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day. == 0) |
| 141 | } |
| 142 | |
| 143 | // Weekday returns the day of the week for the date. |
| 144 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Weekdayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Weekday().() timescip-go gomod github.com/golang/go/src go1.24.0 time/.Weekdayscip-go gomod github.com/golang/go/src go1.24.0 time/Weekday# { |
| 145 | return d.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).Weekdayscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Weekday().() |
| 146 | } |
| 147 | |
| 148 | // MarshalText implements the encoding.TextMarshaler interface. |
| 149 | // The output is the result of d.String(). |
| 150 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) MarshalTextscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#MarshalText().() ([]byte, error) { |
| 151 | return []byte(d.Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#String().()), nil |
| 152 | } |
| 153 | |
| 154 | // UnmarshalText implements the encoding.TextUnmarshaler interface. |
| 155 | // The date is expected to be a string in a format accepted by ParseDate. |
| 156 | func (d *Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) UnmarshalTextscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#UnmarshalText().(data []byte) error { |
| 157 | var err error |
| 158 | *d, err = ParseDatescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDate().(string(data)) |
| 159 | return err |
| 160 | } |
| 161 | |
| 162 | // Value implements the database/sql/driver Valuer interface. |
| 163 | func (d Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Valuescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Value().() (driverscip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/.Valuescip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/Value#, error) { |
| 164 | return d.Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#String().(), nil |
| 165 | } |
| 166 | |
| 167 | // Scan implements the database/sql Scanner interface. |
| 168 | func (d *Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#) Scanscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Scan().(v any) error { |
| 169 | switch vt := v.(type) { |
| 170 | case timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#: |
| 171 | *d = DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(vt) |
| 172 | case *timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#: |
| 173 | if vt != nil { |
| 174 | *d = DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(*vt) |
| 175 | } |
| 176 | case string: |
| 177 | var err error |
| 178 | *d, err = ParseDatescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDate().(vt) |
| 179 | return err |
| 180 | case *string: |
| 181 | var err error |
| 182 | if vt != nil { |
| 183 | *d, err = ParseDatescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDate().(*vt) |
| 184 | } |
| 185 | return err |
| 186 | case []byte: |
| 187 | var err error |
| 188 | *d, err = ParseDatescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDate().(string(vt)) |
| 189 | return err |
| 190 | case *[]byte: |
| 191 | var err error |
| 192 | if vt != nil { |
| 193 | *d, err = ParseDatescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDate().(string(*vt)) |
| 194 | } |
| 195 | return err |
| 196 | case Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#: |
| 197 | *d = vt |
| 198 | case *Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#: |
| 199 | *d = *vt |
| 200 | default: |
| 201 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unsupported scan type for Date: %T", v) |
| 202 | } |
| 203 | return nil |
| 204 | } |
| 205 | |
| 206 | // A Time represents a time with nanosecond precision. |
| 207 | // |
| 208 | // This type does not include location information, and therefore does not |
| 209 | // describe a unique moment in time. |
| 210 | // |
| 211 | // This type exists to represent the TIME type in storage-based APIs like BigQuery. |
| 212 | // Most operations on Times are unlikely to be meaningful. Prefer the DateTime type. |
| 213 | type Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time# struct { |
| 214 | Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour. int // The hour of the day in 24-hour format; range [0-23] |
| 215 | Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute. int // The minute of the hour; range [0-59] |
| 216 | Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. int // The second of the minute; range [0-59] |
| 217 | Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond. int // The nanosecond of the second; range [0-999999999] |
| 218 | } |
| 219 | |
| 220 | // TimeOf returns the Time representing the time of day in which a time occurs |
| 221 | // in that time's location. It ignores the date. |
| 222 | func TimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/TimeOf().(t timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#) Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time# { |
| 223 | var tm Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time# |
| 224 | tm.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour., tm.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute., tm.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. = t.Clockscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Clock().() |
| 225 | tm.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond. = t.Nanosecondscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Nanosecond().() |
| 226 | return tm |
| 227 | } |
| 228 | |
| 229 | // ParseTime parses a string and returns the time value it represents. |
| 230 | // ParseTime accepts an extended form of the RFC3339 partial-time format. After |
| 231 | // the HH:MM:SS part of the string, an optional fractional part may appear, |
| 232 | // consisting of a decimal point followed by one to nine decimal digits. |
| 233 | // (RFC3339 admits only one digit after the decimal point). |
| 234 | func ParseTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseTime().(s string) (Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#, error) { |
| 235 | t, err := timescip-go gomod github.com/golang/go/src go1.24.0 time/.Parsescip-go gomod github.com/golang/go/src go1.24.0 time/Parse().("15:04:05.999999999", s) |
| 236 | if err != nil { |
| 237 | return Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#{}, err |
| 238 | } |
| 239 | return TimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/TimeOf().(t), nil |
| 240 | } |
| 241 | |
| 242 | // String returns the date in the format described in ParseTime. If Nanoseconds |
| 243 | // is zero, no fractional part will be generated. Otherwise, the result will |
| 244 | // end with a fractional part consisting of a decimal point and nine digits. |
| 245 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#String().() string { |
| 246 | s := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%02d:%02d:%02d", t.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour., t.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute., t.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second.) |
| 247 | if t.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond. == 0 { |
| 248 | return s |
| 249 | } |
| 250 | return s + fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(".%09d", t.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond.) |
| 251 | } |
| 252 | |
| 253 | // IsValid reports whether the time is valid. |
| 254 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) IsValidscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#IsValid().() bool { |
| 255 | // Construct a non-zero time. |
| 256 | tm := timescip-go gomod github.com/golang/go/src go1.24.0 time/.Datescip-go gomod github.com/golang/go/src go1.24.0 time/Date().(2, 2, 2, t.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour., t.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute., t.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second., t.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond., timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.) |
| 257 | return TimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/TimeOf().(tm) == t |
| 258 | } |
| 259 | |
| 260 | // IsZero reports whether time fields are set to their default value. |
| 261 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) IsZeroscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#IsZero().() bool { |
| 262 | return (t.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour. == 0) && (t.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute. == 0) && (t.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. == 0) && (t.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond. == 0) |
| 263 | } |
| 264 | |
| 265 | // Before reports whether t occurs before t2. |
| 266 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Before().(t2 Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) bool { |
| 267 | if t.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour. != t2.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour. { |
| 268 | return t.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour. < t2.Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour. |
| 269 | } |
| 270 | if t.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute. != t2.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute. { |
| 271 | return t.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute. < t2.Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute. |
| 272 | } |
| 273 | if t.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. != t2.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. { |
| 274 | return t.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. < t2.Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second. |
| 275 | } |
| 276 | |
| 277 | return t.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond. < t2.Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond. |
| 278 | } |
| 279 | |
| 280 | // After reports whether t occurs after t2. |
| 281 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) Afterscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#After().(t2 Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) bool { |
| 282 | return t2.Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Before().(t) |
| 283 | } |
| 284 | |
| 285 | // Compare compares t and t2. If t is before t2, it returns -1; |
| 286 | // if t is after t2, it returns +1; otherwise it returns 0. |
| 287 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) Comparescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Compare().(t2 Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) int { |
| 288 | if t.Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Before().(t2) { |
| 289 | return -1 |
| 290 | } else if t.Afterscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#After().(t2) { |
| 291 | return +1 |
| 292 | } |
| 293 | return 0 |
| 294 | } |
| 295 | |
| 296 | // MarshalText implements the encoding.TextMarshaler interface. |
| 297 | // The output is the result of t.String(). |
| 298 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) MarshalTextscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#MarshalText().() ([]byte, error) { |
| 299 | return []byte(t.Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#String().()), nil |
| 300 | } |
| 301 | |
| 302 | // UnmarshalText implements the encoding.TextUnmarshaler interface. |
| 303 | // The time is expected to be a string in a format accepted by ParseTime. |
| 304 | func (t *Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) UnmarshalTextscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#UnmarshalText().(data []byte) error { |
| 305 | var err error |
| 306 | *t, err = ParseTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseTime().(string(data)) |
| 307 | return err |
| 308 | } |
| 309 | |
| 310 | // Value implements the database/sql/driver Valuer interface. |
| 311 | func (t Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) Valuescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Value().() (driverscip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/.Valuescip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/Value#, error) { |
| 312 | return t.Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#String().(), nil |
| 313 | } |
| 314 | |
| 315 | // Scan implements the database/sql Scanner interface. |
| 316 | func (t *Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#) Scanscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Scan().(v any) error { |
| 317 | switch vt := v.(type) { |
| 318 | case timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#: |
| 319 | *t = TimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/TimeOf().(vt) |
| 320 | case *timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#: |
| 321 | if vt != nil { |
| 322 | *t = TimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/TimeOf().(*vt) |
| 323 | } |
| 324 | case string: |
| 325 | var err error |
| 326 | *t, err = ParseTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseTime().(vt) |
| 327 | return err |
| 328 | case *string: |
| 329 | var err error |
| 330 | if vt != nil { |
| 331 | *t, err = ParseTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseTime().(*vt) |
| 332 | } |
| 333 | return err |
| 334 | case []byte: |
| 335 | var err error |
| 336 | *t, err = ParseTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseTime().(string(vt)) |
| 337 | return err |
| 338 | case *[]byte: |
| 339 | var err error |
| 340 | if vt != nil { |
| 341 | *t, err = ParseTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseTime().(string(*vt)) |
| 342 | } |
| 343 | return err |
| 344 | case Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#: |
| 345 | *t = vt |
| 346 | case *Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#: |
| 347 | *t = *vt |
| 348 | default: |
| 349 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unsupported scan type for Time: %T", v) |
| 350 | } |
| 351 | return nil |
| 352 | } |
| 353 | |
| 354 | // A DateTime represents a date and time. |
| 355 | // |
| 356 | // This type does not include location information, and therefore does not |
| 357 | // describe a unique moment in time. |
| 358 | type DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime# struct { |
| 359 | Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date. Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date# |
| 360 | Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time. Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time# |
| 361 | } |
| 362 | |
| 363 | // Note: We deliberately do not embed Date into DateTime, to avoid promoting AddDays and Sub. |
| 364 | |
| 365 | // DateTimeOf returns the DateTime in which a time occurs in that time's location. |
| 366 | func DateTimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTimeOf().(t timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#) DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime# { |
| 367 | return DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#{ |
| 368 | Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date.: DateOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateOf().(t), |
| 369 | Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time.: TimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/TimeOf().(t), |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // ParseDateTime parses a string and returns the DateTime it represents. |
| 374 | // ParseDateTime accepts a variant of the RFC3339 date-time format that omits |
| 375 | // the time offset but includes an optional fractional time, as described in |
| 376 | // ParseTime. Informally, the accepted format is |
| 377 | // |
| 378 | // YYYY-MM-DDTHH:MM:SS[.FFFFFFFFF] |
| 379 | // |
| 380 | // where the 'T' may be a lower-case 't'. |
| 381 | func ParseDateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDateTime().(s string) (DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#, error) { |
| 382 | t, err := timescip-go gomod github.com/golang/go/src go1.24.0 time/.Parsescip-go gomod github.com/golang/go/src go1.24.0 time/Parse().("2006-01-02T15:04:05.999999999", s) |
| 383 | if err != nil { |
| 384 | t, err = timescip-go gomod github.com/golang/go/src go1.24.0 time/.Parsescip-go gomod github.com/golang/go/src go1.24.0 time/Parse().("2006-01-02t15:04:05.999999999", s) |
| 385 | if err != nil { |
| 386 | return DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#{}, err |
| 387 | } |
| 388 | } |
| 389 | return DateTimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTimeOf().(t), nil |
| 390 | } |
| 391 | |
| 392 | // String returns the date in the format described in ParseDate. |
| 393 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#String().() string { |
| 394 | return dt.Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date..Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#String().() + "T" + dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#String().() |
| 395 | } |
| 396 | |
| 397 | // IsValid reports whether the datetime is valid. |
| 398 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) IsValidscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#IsValid().() bool { |
| 399 | return dt.Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date..IsValidscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#IsValid().() && dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..IsValidscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#IsValid().() |
| 400 | } |
| 401 | |
| 402 | // In returns the time corresponding to the DateTime in the given location. |
| 403 | // |
| 404 | // If the time is missing or ambigous at the location, In returns the same |
| 405 | // result as time.Date. For example, if loc is America/Indiana/Vincennes, then |
| 406 | // both |
| 407 | // |
| 408 | // time.Date(1955, time.May, 1, 0, 30, 0, 0, loc) |
| 409 | // |
| 410 | // and |
| 411 | // |
| 412 | // civil.DateTime{ |
| 413 | // civil.Date{Year: 1955, Month: time.May, Day: 1}}, |
| 414 | // civil.Time{Minute: 30}}.In(loc) |
| 415 | // |
| 416 | // return 23:30:00 on April 30, 1955. |
| 417 | // |
| 418 | // In panics if loc is nil. |
| 419 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#In().(loc *timescip-go gomod github.com/golang/go/src go1.24.0 time/.Locationscip-go gomod github.com/golang/go/src go1.24.0 time/Location#) timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time# { |
| 420 | return timescip-go gomod github.com/golang/go/src go1.24.0 time/.Datescip-go gomod github.com/golang/go/src go1.24.0 time/Date().(dt.Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date..Yearscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Year., dt.Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date..Monthscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Month., dt.Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date..Dayscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#Day., dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..Hourscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Hour., dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..Minutescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Minute., dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..Secondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Second., dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..Nanosecondscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#Nanosecond., loc) |
| 421 | } |
| 422 | |
| 423 | // Before reports whether dt occurs before dt2. |
| 424 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Before().(dt2 DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) bool { |
| 425 | return dt.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).Beforescip-go gomod github.com/golang/go/src go1.24.0 time/Time#Before().(dt2.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.)) |
| 426 | } |
| 427 | |
| 428 | // After reports whether dt occurs after dt2. |
| 429 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Afterscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#After().(dt2 DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) bool { |
| 430 | return dt2.Beforescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Before().(dt) |
| 431 | } |
| 432 | |
| 433 | // Compare compares dt and dt2. If dt is before dt2, it returns -1; |
| 434 | // if dt is after dt2, it returns +1; otherwise it returns 0. |
| 435 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Comparescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Compare().(dt2 DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) int { |
| 436 | return dt.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.).Comparescip-go gomod github.com/golang/go/src go1.24.0 time/Time#Compare().(dt2.Inscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#In().(timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC.)) |
| 437 | } |
| 438 | |
| 439 | // IsZero reports whether datetime fields are set to their default value. |
| 440 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) IsZeroscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#IsZero().() bool { |
| 441 | return dt.Datescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Date..IsZeroscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Date#IsZero().() && dt.Timescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Time..IsZeroscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/Time#IsZero().() |
| 442 | } |
| 443 | |
| 444 | // MarshalText implements the encoding.TextMarshaler interface. |
| 445 | // The output is the result of dt.String(). |
| 446 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) MarshalTextscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#MarshalText().() ([]byte, error) { |
| 447 | return []byte(dt.Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#String().()), nil |
| 448 | } |
| 449 | |
| 450 | // UnmarshalText implements the encoding.TextUnmarshaler interface. |
| 451 | // The datetime is expected to be a string in a format accepted by ParseDateTime |
| 452 | func (dt *DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) UnmarshalTextscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#UnmarshalText().(data []byte) error { |
| 453 | var err error |
| 454 | *dt, err = ParseDateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDateTime().(string(data)) |
| 455 | return err |
| 456 | } |
| 457 | |
| 458 | // Value implements the database/sql/driver Valuer interface. |
| 459 | func (dt DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Valuescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Value().() (driverscip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/.Valuescip-go gomod github.com/golang/go/src go1.24.0 `database/sql/driver`/Value#, error) { |
| 460 | return dt.Stringscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#String().(), nil |
| 461 | } |
| 462 | |
| 463 | // Scan implements the database/sql Scanner interface. |
| 464 | func (dt *DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#) Scanscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#Scan().(v any) error { |
| 465 | switch vt := v.(type) { |
| 466 | case timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#: |
| 467 | *dt = DateTimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTimeOf().(vt) |
| 468 | case *timescip-go gomod github.com/golang/go/src go1.24.0 time/.Timescip-go gomod github.com/golang/go/src go1.24.0 time/Time#: |
| 469 | if vt != nil { |
| 470 | *dt = DateTimeOfscip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTimeOf().(*vt) |
| 471 | } |
| 472 | case string: |
| 473 | var err error |
| 474 | *dt, err = ParseDateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDateTime().(vt) |
| 475 | return err |
| 476 | case *string: |
| 477 | var err error |
| 478 | if vt != nil { |
| 479 | *dt, err = ParseDateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDateTime().(*vt) |
| 480 | } |
| 481 | return err |
| 482 | case []byte: |
| 483 | var err error |
| 484 | *dt, err = ParseDateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDateTime().(string(vt)) |
| 485 | return err |
| 486 | case *[]byte: |
| 487 | var err error |
| 488 | if vt != nil { |
| 489 | *dt, err = ParseDateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/ParseDateTime().(string(*vt)) |
| 490 | } |
| 491 | return err |
| 492 | case DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#: |
| 493 | *dt = vt |
| 494 | case *DateTimescip-go gomod cloud.google.com/go . `cloud.google.com/go/civil`/DateTime#: |
| 495 | *dt = *vt |
| 496 | default: |
| 497 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unsupported scan type for DateTime: %T", v) |
| 498 | } |
| 499 | return nil |
| 500 | } |