Home > Backend Development > Golang > [Go-carbon version 1.1.1 released] Improve support for mainstream ORM and add public methods

[Go-carbon version 1.1.1 released] Improve support for mainstream ORM and add public methods

藏色散人
Release: 2020-09-19 09:23:50
forward
2646 people have browsed it

The following is introduced by the golang tutorial column [Go-carbon1.1.1 version released] improves support for mainstream ORM, adds public methods, and hopes to Friends in need help!

carbon is a lightweight, semantic, IDE-friendly date and time processing library. It is the Golang implementation version of the PHP Carbon library. The original intention is to get rid of Golang's anti-humanity 2006-01-02 15:04 :05 Format time design, support chain calls and mainstream ORMs such as gorm and xrom

If you think it is good, please give it a star

github:https://github.com/golang-module/carbon
gitee:ghttps://gitee.com/go-package/carbon
Copy after login

Installation

go get -u gitee.com/go-package/carbon
Copy after login

Initialization

import (
 "gitee.com/go-package/carbon")// 初始化,默认时区为Local,即服务器所在时区c := carbon.New()// 初始化并设置时区c := carbon.New().Timezone(carbon.PRC)
Copy after login

For more time zone constants, please view the const.go (https://gitee.com/go-package/carbon/blob/master/const.go) file

Update log
  • Fix the json formatting when the time type field value in the database is null or 0000-00-00 00:00:00 The last bug is 0001-01-01 00:00:00
  • The time zone constant is moved to the const.go file
  • The private method is extracted to the independent file private.go
  • Optimize the code organization structure and streamline the code
  • Added support for json output time formatting of the xorm structure, supporting the output of multiple standard time formats
  • Added StartOf and EndOf class methods to obtain the start Time and end time
  • Added IsStartOf and IsEndOf class methods to determine whether it is the start time and end time
  • Added new ToDateStartString method to convert into date start time
  • Added new ToDateEndString method Convert to date end time
  • Add new ToTimeStartString method to convert to hour start time
  • Add new ToTimeEndString method to convert to hour end time

The above is the detailed content of [Go-carbon version 1.1.1 released] Improve support for mainstream ORM and add public methods. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template