gtime_time_wrapper.go 624 B

12345678910111213141516171819202122232425
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gtime
  7. import (
  8. "time"
  9. )
  10. // wrapper is a wrapper for stdlib struct time.Time.
  11. // It's used for overwriting some functions of time.Time, for example: String.
  12. type wrapper struct {
  13. time.Time
  14. }
  15. // String overwrites the String function of time.Time.
  16. func (t wrapper) String() string {
  17. if t.IsZero() {
  18. return ""
  19. }
  20. return t.Format("2006-01-02 15:04:05")
  21. }