github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/bson/bsonoptions/time_codec_options.go (about) 1 // Copyright (C) MongoDB, Inc. 2017-present. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 7 package bsonoptions 8 9 // TimeCodecOptions represents all possible options for time.Time encoding and decoding. 10 // 11 // Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal 12 // and unmarshal behavior instead. 13 type TimeCodecOptions struct { 14 UseLocalTimeZone *bool // Specifies if we should decode into the local time zone. Defaults to false. 15 } 16 17 // TimeCodec creates a new *TimeCodecOptions 18 // 19 // Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal 20 // and unmarshal behavior instead. 21 func TimeCodec() *TimeCodecOptions { 22 return &TimeCodecOptions{} 23 } 24 25 // SetUseLocalTimeZone specifies if we should decode into the local time zone. Defaults to false. 26 // 27 // Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.UseLocalTimeZone] instead. 28 func (t *TimeCodecOptions) SetUseLocalTimeZone(b bool) *TimeCodecOptions { 29 t.UseLocalTimeZone = &b 30 return t 31 } 32 33 // MergeTimeCodecOptions combines the given *TimeCodecOptions into a single *TimeCodecOptions in a last one wins fashion. 34 // 35 // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a 36 // single options struct instead. 37 func MergeTimeCodecOptions(opts ...*TimeCodecOptions) *TimeCodecOptions { 38 t := TimeCodec() 39 for _, opt := range opts { 40 if opt == nil { 41 continue 42 } 43 if opt.UseLocalTimeZone != nil { 44 t.UseLocalTimeZone = opt.UseLocalTimeZone 45 } 46 } 47 48 return t 49 }