GolangNote

Golang笔记

中国农历算法之golang版本

Permalink

中国农历算法之 golang 版本,农历年以春节变更,不是以立春为界。

示例:

Go: 农历计算
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package main

import (
    "fmt"
    "github.com/FrankWong1213/golang-lunar"
    "time"
)

func main() {
    now := time.Now()
    fmt.Println(now)
    fmt.Println(lunar.Lunar(now.Format("20060102")))
    fmt.Println(lunar.Lunar("20151025"))
}

输出:

plaintext: 农历计算输出
1
2
3
2015-10-25 20:50:45.476583331 +0800 CST
乙未羊年九月十三
乙未羊年九月十三

项目地址: https://github.com/FrankWong1213/golang-lunar

本文网址: https://golangnote.com/topic/89.html 转摘请注明来源

Related articles

Golang 把cookie 字符串解析为cookie 结构

在做爬虫时有时候会遇到需要带已登录的 cookie 请求,这个时候最简单的方法是在浏览器登录后,在开发者面板找到cookie 字符串,然后拷贝粘贴。这就面临一个问题需要把cookie 字符串解析成Go 语言 cookie 结构体。...

Golang 生成防识别的图片验证码

验证码 captcha 是对抗密码强力破解、垃圾信息的有效方式,一般用于用户注册、登录,当检测到频繁发帖时也会启用验证码。下面介绍用golang 生成防机器识别的图片验证码。...

Write a Comment to "中国农历算法之golang版本"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 0ms