feat(quando-j2s): implement core Date type and conversions
- Add Date struct with time.Time and Lang fields - Implement package-level constructors: Now(), From(time.Time) - Add conversion methods: Time(), Unix(), FromUnix(int64) - Support negative Unix timestamps (dates before 1970) - Support full time.Time range (year 0001-9999+) - Add WithLang() for i18n support (placeholder) - Create package documentation in quando.go - Comprehensive unit tests with 100% coverage - Example tests for godoc - Verify immutability through tests All acceptance criteria met: ✓ Date struct defined with time.Time and Lang fields ✓ Now() returns current date ✓ From(time.Time) converts to Date ✓ Time() extracts underlying time.Time ✓ Unix() returns Unix timestamp (int64) ✓ FromUnix(int64) creates Date from timestamp ✓ Unit tests with 100% coverage (exceeds 95% requirement) ✓ Godoc comments for all exported types/functions ✓ Example tests in example_test.go
This commit is contained in:
parent
f748b0e134
commit
6353f28af5
5 changed files with 545 additions and 2 deletions
50
quando.go
Normal file
50
quando.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Package quando provides intuitive and idiomatic date calculations for Go.
|
||||
//
|
||||
// quando wraps the standard library's time.Time and provides a fluent API
|
||||
// for complex date operations that are cumbersome with the standard library alone.
|
||||
//
|
||||
// Key features:
|
||||
// - Fluent API for method chaining
|
||||
// - Month-end aware arithmetic (Jan 31 + 1 month = Feb 28)
|
||||
// - DST-safe calendar-based operations
|
||||
// - Zero dependencies (stdlib only)
|
||||
// - Immutable and thread-safe
|
||||
// - Internationalization support (EN, DE in Phase 1)
|
||||
// - Clock abstraction for testable code
|
||||
//
|
||||
// # Quick Start
|
||||
//
|
||||
// Get the current date:
|
||||
//
|
||||
// now := quando.Now()
|
||||
//
|
||||
// Create from time.Time:
|
||||
//
|
||||
// date := quando.From(time.Now())
|
||||
//
|
||||
// Create from Unix timestamp:
|
||||
//
|
||||
// date := quando.FromUnix(1707480000)
|
||||
//
|
||||
// Convert back to time.Time:
|
||||
//
|
||||
// t := date.Time()
|
||||
//
|
||||
// # Design Principles
|
||||
//
|
||||
// Immutability: All operations return new Date instances. Original values
|
||||
// are never modified, making Date thread-safe by design.
|
||||
//
|
||||
// Fluent API: Methods can be chained naturally:
|
||||
//
|
||||
// result := quando.Now().Add(2, Months).StartOf(Week)
|
||||
//
|
||||
// Stdlib Delegation: quando wraps time.Time rather than reimplementing
|
||||
// time calculations, ensuring correctness and compatibility.
|
||||
//
|
||||
// No Panics: All errors are returned as values (except Must* variants
|
||||
// intended for tests/initialization).
|
||||
package quando
|
||||
|
||||
// Version is the current version of the quando library.
|
||||
const Version = "0.1.0"
|
||||
Loading…
Add table
Add a link
Reference in a new issue