# timeago
**Repository Path**: shining-star-c/timeago
## Basic Information
- **Project Name**: timeago
- **Description**: 对时间进行处理,显示就近时间单位大致信息,具体看readme
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-05-05
- **Last Updated**: 2022-06-12
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# timeago
#### 介绍
timeago
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. func timeago.Timeago(datatime interface{},loc string,rule ...string)string
能将输入的各种时间类型变为“几秒前”,“几小时前”,“几天前”等显示,最大显示为292年,datatime是输入的时间,当输入时间类型时可以直接转换,当输入的是int类型时会识别为Unix数据并以此生成时间,前两个不受loc字段影响,建议录入"",当输入的是字符串时,字符串格式必须为“2006-01-02 15:04:05”,并且会受loc参数影响,当输入的是""时,为本地时区。当添加rule字段并且值为"week"时,会显示“今天xx:xx”,“昨天xx:xx”,“明天xx:xx”,“上个星期xx:xx”,“这个星期xx:xx”,“下个星期xx:xx”,超出这三个星期的时间段后显示xx年xx月xx日xx时xx分。
timeago.Timeago(time.Now().Add(2*time.Hour),"") //显示“2 小时后”
timeago.Timeago(time.Now().Add(-2*time.Hour),"") //显示“2 小时前”
timeago.Timeago("2022-05-08 09:28:52","") //显示“2 小时前”
timeago.Timeago("2022-05-08 09:28:52","UTC") //显示“6 小时后”
timeago.Timeago(69595959,"") //显示“50年前”
timeago.Timeago(time.Now(),"","week") //显示“今天09:35”
timeago.Timeago(time.Now().Add(-7*time.Hour*24),"","week") //显示“上个星期日09:35”
timeago.Timeago(time.Now().Add(20*time.Hour*24),"","week") //显示“2022年05月28日 09:28:52”
2. func timeago.Location(loc string)(int,error)
更改默认输入字符串时间的时区
timeago.Location("UTC")//格林尼治时间
timeago.Location("America/Los_Angeles")//美国洛杉矶时区
3. func timeago.Word(word string)(error)
更改显示的语言,默认为汉语,目前支持英语(en)和汉语(chs)
timeago.Word("en")//改为英文
timeago.Word("chs")//改为汉语
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)