joda-time项目的go语言实现

abelli5 · 2021-07-03 21:50:42 · 1577 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2021-07-03 21:50:42 的主题,其中的信息可能已经有所发展或是发生改变。

大部分时间做 kotlin/java 开发,觉得 joda-time 用着很方便。老长时间不用 golang 了,写个项目练练手。 golang jodatime 正在开发中,功能还不完善,请多指教: https://github.com/abelli5/jodatime


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1577 次点击  
加入收藏 微博
2 回复  |  直到 2021-07-05 00:48:38
abelli5
abelli5 · #1 · 4年之前

补充了日期字段的 add/with 等方法:

·// add year/month/... and return copy of the instance
·// 增加年月日等字段的值,并返回新实例 
·jt := jodatime.DateHour(2024, 1, 8, 6).AddYear(5).AddMonth(3).AddDay(-6).AddHour(7)

·// set with-year/month/... and return copy of the instance
·// 设置日期字段并返回新实例
·jt = jodatime.DateFull(2021, 3, 4, 5, 6, 7, 8).WithYear(2020).WithMonth(2).WithDay(3).WithHour(4).WithMinute(5).WithSecond(6).WithNanosecond(0)

体会 闰年、闰月略微复杂些,感觉还有待优化。暂不支持闰秒,这个功能再考虑下~

gouguoyin
gouguoyin · #2 · 4年之前
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传