Updated code examples in README
This commit is contained in:
parent
f7b6b5b525
commit
da180f8af7
1 changed files with 6 additions and 6 deletions
12
README.md
12
README.md
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Fluent API**: Chain operations naturally: `quando.Now().Add(2, Months).StartOf(Week)`
|
- **Fluent API**: Chain operations naturally: `quando.Now().Add(2, quando.Months).StartOf(quando.Weeks)`
|
||||||
- **Month-End Aware**: Handles edge cases like `Jan 31 + 1 month = Feb 28`
|
- **Month-End Aware**: Handles edge cases like `Jan 31 + 1 month = Feb 28`
|
||||||
- **DST Safe**: Calendar-based arithmetic (not clock-based)
|
- **DST Safe**: Calendar-based arithmetic (not clock-based)
|
||||||
- **Zero Dependencies**: Only Go stdlib
|
- **Zero Dependencies**: Only Go stdlib
|
||||||
|
|
@ -40,8 +40,8 @@ date := quando.From(time.Date(2026, 1, 31, 0, 0, 0, 0, time.UTC))
|
||||||
result := date.Add(1, quando.Months) // Feb 28, 2026 (not overflow)
|
result := date.Add(1, quando.Months) // Feb 28, 2026 (not overflow)
|
||||||
|
|
||||||
// Snap to boundaries
|
// Snap to boundaries
|
||||||
monday := quando.Now().StartOf(quando.Week) // This week's Monday 00:00
|
monday := quando.Now().StartOf(quando.Weeks) // This week's Monday 00:00
|
||||||
endOfMonth := quando.Now().EndOf(quando.Month) // Last day of month 23:59:59
|
endOfMonth := quando.Now().EndOf(quando.Months) // Last day of month 23:59:59
|
||||||
|
|
||||||
// Next/Previous dates
|
// Next/Previous dates
|
||||||
nextFriday := quando.Now().Next(time.Friday)
|
nextFriday := quando.Now().Next(time.Friday)
|
||||||
|
|
@ -75,8 +75,8 @@ dayOfYear := date.DayOfYear() // 1-366
|
||||||
// Complex chaining for real-world scenarios
|
// Complex chaining for real-world scenarios
|
||||||
reportDeadline := quando.Now().
|
reportDeadline := quando.Now().
|
||||||
Add(1, quando.Quarters). // Next quarter
|
Add(1, quando.Quarters). // Next quarter
|
||||||
EndOf(quando.Quarter). // Last day of that quarter
|
EndOf(quando.Quarters). // Last day of that quarter
|
||||||
StartOf(quando.Week). // Monday of that week
|
StartOf(quando.Weeks). // Monday of that week
|
||||||
Add(-1, quando.Weeks) // One week before
|
Add(-1, quando.Weeks) // One week before
|
||||||
|
|
||||||
// Multilingual formatting
|
// Multilingual formatting
|
||||||
|
|
@ -194,7 +194,7 @@ startOfWeek = time.Date(startOfWeek.Year(), startOfWeek.Month(),
|
||||||
startOfWeek.Day(), 0, 0, 0, 0, startOfWeek.Location())
|
startOfWeek.Day(), 0, 0, 0, 0, startOfWeek.Location())
|
||||||
|
|
||||||
// quando: One method call
|
// quando: One method call
|
||||||
startOfWeek := quando.Now().StartOf(quando.Week)
|
startOfWeek := quando.Now().StartOf(quando.Weeks)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Feature Comparison
|
### Feature Comparison
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue