Go carbon version 1.3.3 has been released, adding the method of obtaining constellation and judging whether it is a constellation

Time:2021-7-28

Carbon is a lightweight, semantic and developer friendly golang time processing library, which supports chain calls, lunar calendar, Gorm, xorm and other mainstream orm

If you feel good, please give a star

github:github.com/golang-module/carbon

gitee:gitee.com/go-package/carbon

Update log
  • A constellation () method is added to obtain constellations, which supports multiple languages
  • Add isXXX () series methods to judge whether it is a constellation
  • A new tomonthstring() method is added to output a complete month string, which supports multiple languages
  • The toshortmonthstring() method is added to output the abbreviated month string, which supports multiple languages
  • A new toweekstring() method is added to output a complete week string, which supports multiple languages
  • Added toshortweekstring() method to output abbreviated week string, supporting multiple languages
  • Fix the bug with duplicate values of the heavenlystems variable in the calendar.go file
//Get constellation
carbon.Parse("2020-08-05 13:14:15").Constellation() // Leo
Carbon. Parse ("2020-08-05 13:14:15"). Setlocale ("zh CN"). Constellation() // LEO

//Is it Aries
carbon.Parse("2020-08-05 13:14:15").IsAries() // false
//Is it Taurus
carbon.Parse("2020-08-05 13:14:15").IsTaurus() // false
//Is it Gemini
carbon.Parse("2020-08-05 13:14:15").IsGemini() // false
//Is it cancer
carbon.Parse("2020-08-05 13:14:15").IsCancer() // false
//Is it Leo
carbon.Parse("2020-08-05 13:14:15").IsLeo() // true
//Is it Virgo
carbon.Parse("2020-08-05 13:14:15").IsVirgo() // false
//Is it a Libra
carbon.Parse("2020-08-05 13:14:15").IsLibra() // false
//Is it Scorpio
carbon.Parse("2020-08-05 13:14:15").IsScorpio() // false
//Is it Sagittarius
carbon.Parse("2020-08-05 13:14:15").IsSagittarius() // false
//Is it Capricorn
carbon.Parse("2020-08-05 13:14:15").IsCapricorn() // false
//Is it Aquarius
carbon.Parse("2020-08-05 13:14:15").IsAquarius() // false
//Is it Pisces
carbon.Parse("2020-08-05 13:14:15").IsPisces() // false

//Output full month string
carbon.Parse("2020-08-05 13:14:15").ToMonthString() // August
carbon.Parse("2020-08-05 13:14:15").SetLocale("en").ToMonthString() // August
Carbon. Parse ("2020-08-05 13:14:15"). Setlocale ("zh CN"). Tomonthstring() // August

//Output abbreviated month string
carbon.Parse("2020-08-05 13:14:15").ToShortMonthString() // Aug
carbon.Parse("2020-08-05 13:14:15").SetLocale("en").ToShortMonthString() // Aug
Carbon. Parse ("2020-08-05 13:14:15"). Setlocale ("zh CN"). Toshortmonthstring() // August

//Output full week string
carbon.Parse("2020-08-05 13:14:15").ToWeekString() // Tuesday
carbon.Parse("2020-08-05 13:14:15").SetLocale("en").ToWeekString() // Tuesday
Carbon. Parse ("2020-08-05 13:14:15"). Setlocale ("zh CN"). Toweekstring() // Tuesday

//Output abbreviated week string
carbon.Parse("2020-08-05 13:14:15").ToShortWeekString() // Tue
carbon.Parse("2020-08-05 13:14:15").SetLocale("en").ToShortWeekString() // Tue
Carbon. Parse ("2020-08-05 13:14:15"). Setlocale ("zh CN"). Toshortweekstring() // Tuesday

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]