Skip to content

Commit 3a5a1ff

Browse files
committed
Merge branch 'master' into v3
2 parents c82cdc2 + 5a7f6fa commit 3a5a1ff

13 files changed

Lines changed: 110 additions & 71 deletions

File tree

.github/workflows/go.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@ name: Go
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
1111
name: Build
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
go_version: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23', '1.24']
15+
go_version: [1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22, 1.23, 1.24, 1.25]
1616

1717
steps:
18-
- name: Check out code into the Go module directory
19-
uses: actions/checkout@v1
18+
- uses: actions/checkout@v3
2019

21-
- name: Setup the correct timezone
22-
run: sudo cp -f /usr/share/zoneinfo/Europe/Kiev /etc/localtime
20+
- name: Setup the correct timezone
21+
run: sudo cp -f /usr/share/zoneinfo/Europe/Kiev /etc/localtime
2322

24-
- name: Run tests
25-
run: make
23+
- name: Set up Go
24+
uses: actions/setup-go@v4
25+
26+
- name: Install golangci-lint
27+
run: curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0
28+
29+
- name: Run checks
30+
run: make check

CHANGELOG.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,53 @@
11
# Release Notes v3
22

3+
## v3.3.2 (2026-02-08)
4+
5+
- 🧑 Added linting and formatting check for GitHub actions.
6+
- 🧑 Code refactoring and improvements for better readability and maintainability.
7+
38
## v3.3.1 (2025-06-20)
4-
- Added Docker to the project
9+
10+
- 🧑 Added Container Engines like Docker and Podman to the project.
511

612
## v3.3.0 (2025-06-16)
7-
- Now you can parse different times of timestamps, such as `string`, `int64`, `uint`, `uint64`, `int32`, `uint32`
13+
14+
- ✨ Now you can parse different times of timestamps, such as `string`, `int64`, `uint`, `uint64`, `int32`, `uint32`.
815

916
## v3.2.2 (2025-06-04)
10-
- Change so that all JSON files are included in the final binary by using `go:embed` functionality
11-
- Remove support for go version 1.13, 1.14, 1.15 because they do not have `go:embed`
17+
18+
- ✨ Change so that all JSON files are included in the final binary by using `go:embed` functionality.
19+
- ⚠️ Remove support for go version 1.13, 1.14, 1.15 because they do not have `go:embed`.
1220

1321
## v3.2.1 (2024-12-06)
14-
- Bug fix with incorrect Russian, Ukrainian, and Belarusian languages rules
15-
- Added more tests for Russian, Ukrainian, and Belarusian languages for testing seconds
22+
23+
- 🐛 Bug fix with incorrect Russian, Ukrainian, and Belarusian languages rules.
24+
- 🧑 Added more tests for Russian, Ukrainian, and Belarusian languages for testing seconds.
1625

1726
## v3.2.0 (2024-11-27)
18-
- Added support for Belarusian language 🇧🇾
19-
- Added support for Spanish language 🇪🇸
20-
- Added support for Japanese language 🇯🇵
21-
- Added support for French language 🇫🇷
22-
- Code refactoring and improvements for better readability and maintainability
27+
28+
- ✨ Added support for Belarusian language 🇧🇾.
29+
- ✨ Added support for Spanish language 🇪🇸.
30+
- ✨ Added support for Japanese language 🇯🇵.
31+
- ✨ Added support for French language 🇫🇷.
32+
- 🧑 Code refactoring and improvements for better readability and maintainability.
2333

2434
## v3.1.0 (2024-11-25)
25-
- Updated the `LICENSE.md` file
26-
- Refactored codebase to make it more readable and maintainable
27-
- Added [OnlineThreshold](https://time-ago.github.io/v3/configurations.html#thresholds) parameter to the configurations to set the threshold for the "Online" status
28-
- Added [JustNowThreshold](https://time-ago.github.io/v3/configurations.html#thresholds) parameter to the configurations to set the threshold for the "Just now" status
29-
- Added support for Chinese Simplified language 🇨🇳
30-
- **POTENTIAL BREAK**. Might break your code if you were using the `Option` type or option constants directly. Which wasn't documented for public use.
31-
- Rename `Option` type to `opt` making it unexported
32-
- Add prefix to option constants `Opt` to make them like `OptOnline`, `OptNoSuffix`, etc.
35+
36+
- 📝 Updated the `LICENSE.md` file
37+
- 🧑 Refactored codebase to make it more readable and maintainable
38+
- ✨ Added [OnlineThreshold](https://time-ago.github.io/v3/configurations.html#thresholds) parameter to the configurations to set the threshold for the "Online" status
39+
- ✨ Added [JustNowThreshold](https://time-ago.github.io/v3/configurations.html#thresholds) parameter to the configurations to set the threshold for the "Just now" status
40+
- ✨ Added support for Chinese Simplified language 🇨🇳
41+
- ⚠️ **POTENTIAL BREAK**. Might break your code if you were using the `Option` type or option constants directly. Which wasn't documented for public use.
42+
- Rename `Option` type to `opt` making it unexported
43+
- Add prefix to option constants `Opt` to make them like `OptOnline`, `OptNoSuffix`, etc.
3344

3445
## v3.0.0 (2024-11-22)
46+
3547
> BREAKING CHANGES!
3648
3749
[Upgrade Guide from v2 to v3](https://time-ago.github.io/v3/upgrade.html)
50+
3851
- **Improved error handling**. The `Parse` function now returns an error as the second returned value
3952
- **Update package namespace**. Changed package namespace to `github.com/SerhiiCho/timeago/v3`
4053
- **Rename a function**. Renamed `SetConfig` function to `Configure` to make it better fit into Go naming conventions
@@ -44,6 +57,6 @@
4457

4558
> Follow the [Upgrade Guide](https://time-ago.github.io/upgrade.html) from v2 to v3
4659
47-
4860
## [Release Notes v2](.github/CHANGELOGV2.md)
61+
4962
## [Release Notes v1](.github/CHANGELOGV1.md)

Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
.PHONY: test
22
test:
3-
go test -cover -timeout 10s ./...
4-
go vet ./...
3+
@clear || true
4+
go test ./...
5+
@echo "✅ All tests passed!"
56

67
.PHONY: cover
78
cover:
89
go test -coverprofile=coverage.out
910
go tool cover -html=coverage.out
1011
rm coverage.out
1112

12-
.PHONY: push
13-
push:
14-
make test
15-
git pull origin HEAD
16-
git push origin HEAD
13+
.PHONY: fmt
14+
fmt:
15+
@go fmt ./...
16+
@echo "✅ Code formatted!"
17+
18+
.PHONY: lint
19+
lint:
20+
@golangci-lint run
21+
@echo "✅ Linting passed!"
22+
23+
.PHONY: todo
24+
todo:
25+
@if grep -I --exclude="Makefile" --exclude-dir=".git" -r TODO .; then \
26+
echo "❌ Found TODOs" >&2; \
27+
exit 1; \
28+
fi
29+
30+
.PHONY: check
31+
check: test fmt lint todo
1732

1833
.DEFAULT_GOAL := test

README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![golang](https://serhii.io/storage/other/timeago.png)
1+
![golang](https://serhiicho.com/storage/other/timeago.png)
22

33
[![Go](https://github.com/SerhiiCho/timeago/actions/workflows/go.yml/badge.svg)](https://github.com/SerhiiCho/timeago/actions/workflows/go.yml)
44
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FSerhiiCho%2Ftimeago%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/SerhiiCho/timeago/goto?ref=master)
@@ -25,22 +25,36 @@ Here are some of the naming conventions used in the codebase and their meanings
2525
- **suffix** - the suffix `ago` in the final output like `1 minute ago`, `2 minutes ago`, `3 minutes ago`, etc.
2626
- **time since** - the final output result like `2 minutes`, `3 minutes ago`, `Just now`, `Online`, `3 years ago` etc.
2727

28+
## Star History
29+
[![Star History Chart](https://api.star-history.com/svg?repos=SerhiiCho/timeago&type=Date)](https://www.star-history.com/#SerhiiCho/timeago&Date)
30+
2831
## License
2932
This project is open-sourced software licensed under the [MIT license](https://github.com/SerhiiCho/timeago/blob/master/LICENSE.md).
3033

31-
## Development
32-
### Without Docker
33-
You'll need to have Go installed on your machine. Also, if you want to run Makefile commands, you'll need to have `make` installed as well.
34+
## Contribute
35+
### With Container Engine
36+
#### Build an Image
37+
To build an image, navigate to the root of the project and run this command.
38+
39+
With Podman:
40+
```bash
41+
podman-compose build
42+
```
3443

35-
### With Docker
36-
#### Build an image
37-
To build an image, navigate to the root of the project that contains `Dockerfile` and run this command:
44+
With Docker:
3845
```bash
3946
docker compose build
4047
```
4148

42-
#### Run the container
43-
To run a container, navigate to the root of the project that contains `Dockerfile` and run this command to enter the Linux container with Go installed:
49+
#### Run the Container
50+
To run a container, navigate to the root of the project and run this command to enter the Linux container with Go installed.
51+
52+
With Podman:
53+
```bash
54+
podman-compose run --rm app
55+
```
56+
57+
With Docker:
4458
```bash
4559
docker compose run --rm app
4660
```

docker-compose.yml renamed to compose.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: serhii-timeago
33
services:
44
app:
55
image: serhii-timeago
6-
build:
7-
context: .
6+
build: .
87
volumes:
9-
- .:/app
8+
- .:/app:z

config_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func TestIsLocationProvided(t *testing.T) {
3737

3838
for _, tc := range cases {
3939
t.Run(tc.name, func(t *testing.T) {
40-
c := NewConfig("en", tc.loc, []LangSet{}, 60, 60)
41-
actual := c.isLocationProvided()
40+
conf := NewConfig("en", tc.loc, []LangSet{}, 60, 60)
41+
actual := conf.isLocationProvided()
4242

4343
if actual != tc.expect {
4444
t.Fatalf("Expected %v, but got %v", tc.expect, actual)
@@ -92,7 +92,6 @@ func TestCustomTranslations(t *testing.T) {
9292
})
9393

9494
date := utils.UnixFromPastDate(tc.time)
95-
9695
if res, _ := Parse(date); res != tc.expect {
9796
t.Errorf("Result must be %q, but got %q instead", tc.expect, res)
9897
}

langset.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type LangSet struct {
2727

2828
func newLangSet() (*LangSet, error) {
2929
filePath := fmt.Sprintf("langs/%s.json", conf.Language)
30-
3130
if cache, ok := cachedJsonRes[filePath]; ok {
3231
return cache, nil
3332
}

option.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ const (
2626
OptNoSuffix opt = "noSuffix"
2727
)
2828

29-
func enableOption(o opt) {
30-
options = append(options, o)
29+
func enableOption(opt opt) {
30+
options = append(options, opt)
3131
}
3232

3333
func enableOptions(opts []opt) {
34-
for _, opt := range opts {
35-
enableOption(opt)
34+
for i := range opts {
35+
enableOption(opts[i])
3636
}
3737
}
3838

39-
func optionIsEnabled(o opt) bool {
40-
for _, option := range options {
41-
if option == o {
39+
func optionIsEnabled(opt opt) bool {
40+
for i := range options {
41+
if options[i] == opt {
4242
return true
4343
}
4444
}

rules.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var grammarRules = func(num int) map[string]*Rule {
4545

4646
func identifyGrammarRules(num int, lang string) (*Rule, error) {
4747
rules := grammarRules(num)
48-
4948
if v, ok := rules[lang]; ok {
5049
return v, nil
5150
}
@@ -56,5 +55,5 @@ func identifyGrammarRules(num int, lang string) (*Rule, error) {
5655
}
5756
}
5857

59-
return nil, utils.Errorf("Language '" + lang + "' not found")
58+
return nil, utils.Errorf("Language '%s' not found", lang)
6059
}

timeago.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ func findLangForms(timeInSec int) (LangForms, int) {
251251
if nums.Months == 0 {
252252
nums.Months = 1
253253
}
254-
255254
return langSet.Month, nums.Months
256255
}
257256

@@ -262,7 +261,6 @@ func computeSuffix() string {
262261
if optionIsEnabled(OptNoSuffix) || optionIsEnabled(OptUpcoming) {
263262
return ""
264263
}
265-
266264
return langSet.Ago
267265
}
268266

0 commit comments

Comments
 (0)