You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: time.go
    path of file: ./repos/bk-cmdb/src/common/metadata
    
    the code of the file until where you have to start completion: /*
 * Tencent is pleased to support the open source community by making 蓝鲸 available.
 * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
 * Licensed under the MIT License (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * http://opensource.org/licenses/MIT
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions and
 * limitations under the License.
 */

package metadata

import (
	"database/sql/driver"
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"time"

	"github.com/coccyx/timeparse
    
func (t *Time) UnmarshalBSONValue(typo bsontype.Type, raw []byte) error {
	switch typo {
	case bsontype.Timestamp:
		// 0x11 timestamp
		return bson.Unmarshal(raw, &t.Time)
	case bsontype.Double:
		rv := bson.RawValue{Type: bsontype.Double, Value: raw}
		if dt, ok := rv.DoubleOK(); ok {
			t.Time = time.Unix(int64(dt/1000), int64(uint64(dt)%1000*1000000))
			return nil
		}
		return nil
	case bsontype.DateTime:
		rv := bson.RawValue{Type: bsontype.DateTime, Value: raw}
		t.Time = rv.Time()
		return nil
	case bsontype.String:
		rawStr := bson.RawValue{Type: bsontype.String, Value: raw}
		strTime := strings.TrimSpace(strings.Trim(rawStr.String(), "\""))

		vTime, err := time.Parse(time.RFC3339Nano, strTime)
		if err == nil {
			t.Time = vTime
			return nil
		}

		vTime, err = time.Parse(time.RFC3339, strTime)
		if err == nil {
			t.Time = vTime
			return nil
		}

		vTime, err = timeparser.TimeParser(strTime)
		if err == nil {
			t.Time = vTime
			return nil
		}

		return fmt.Errorf("cannot decode %v into a metadata.Time, err:%s", bsontype.String, err.Error())

	}

	// for compatibility purpose
	tt := tmptime{}
	err := bson.Unmarshal(raw, &tt)
	t.Time = tt.Time

	return err
}