lesli_date 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/readme.md CHANGED
@@ -1,62 +1,222 @@
1
- <div align="center" class="documentation-header">
2
- <img width="100" alt="LesliDate logo" src="./docs/images/date-logo.svg" />
3
- <h3 align="center">Standard Datetime Formatter for The Lesli Framework.</h3>
1
+ <div align="center">
2
+ <h1 align="center">
3
+ <img width="100" alt="LesliDate" src="./docs/images/date-logo.svg" />
4
+ </h1>
5
+ <h3 align="center">Consistent date and time formatting for the Lesli Framework.</h3>
4
6
  </div>
5
7
 
6
8
  <br />
7
- <hr/>
8
9
 
9
- <div align="center" class="documentation-statics">
10
- <a target="blank" href="https://github.com/LesliTech/LesliDate/actions">
11
- <img alt="Tests passing" src="https://img.shields.io/badge/Tests-passing-green?style=for-the-badge&logo=github">
10
+ <div align="center">
11
+ <a target="_blank" href="https://github.com/LesliTech/LesliDate/actions/workflows/lesli-ci-gem.yaml">
12
+ <img alt="LesliDate test status" src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliDate/lesli-ci-gem.yaml?branch=main&style=for-the-badge&logo=github&label=tests">
12
13
  </a>
13
- <a target="blank" href="https://rubygems.org/gems/lesli_date">
14
+ <a target="_blank" href="https://rubygems.org/gems/lesli_date">
14
15
  <img alt="Gem Version" src="https://img.shields.io/gem/v/lesli_date?style=for-the-badge&logo=ruby">
15
16
  </a>
16
- <a target="blank" href="https://codecov.io/github/LesliTech/LesliDate">
17
+ <a target="_blank" href="https://codecov.io/github/LesliTech/LesliDate">
17
18
  <img alt="Codecov" src="https://img.shields.io/codecov/c/github/LesliTech/LesliDate?style=for-the-badge&logo=codecov">
18
19
  </a>
19
- <a target="blank" href="https://sonarcloud.io/project/overview?id=LesliTech_LesliView">
20
- <img alt="Sonar Quality Gate" src="https://img.shields.io/sonar/quality_gate/LesliTech_LesliView?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud&label=Quality">
20
+ <a target="_blank" href="https://sonarcloud.io/project/overview?id=LesliTech_LesliDate">
21
+ <img alt="Sonar Quality Gate" src="https://img.shields.io/sonar/quality_gate/LesliTech_LesliDate?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarqubecloud&label=Quality">
21
22
  </a>
22
23
  </div>
23
24
 
24
- <hr/>
25
25
  <br />
26
26
 
27
+ ---
27
28
 
28
- ### Quick start
29
+ <br />
30
+
31
+ ## Introduction
32
+
33
+ LesliDate provides date and time formatting utilities for applications built with the [Lesli Framework](https://github.com/LesliTech/Lesli).
34
+
35
+ It applies the host application's Lesli date, time-zone, and format configuration while providing compatible SQL expressions for SQLite and PostgreSQL.
36
+
37
+ <br />
38
+
39
+ ## Features
40
+
41
+ - Date, time, and date-time formatting
42
+ - Human-readable date and time formats
43
+ - Time-zone-aware parsing and output
44
+ - ISO 8601 and custom input formats
45
+ - SQLite- and PostgreSQL-compatible date expressions
46
+ - Database-safe current timestamp helpers
47
+
48
+ <br />
49
+
50
+ ## Installation
51
+
52
+ Requires Ruby 3.3 or later, ActiveSupport and ActiveRecord 8.0.x or 8.1.x,
53
+ and I18n `>= 1.6`, `< 2`. The host application supplies `Lesli.config.datetime`
54
+ and its database driver. LesliDate ships no locale data.
55
+
56
+ Add LesliDate to the application:
29
57
 
30
58
  ```shell
31
- # Add LesliAdmin engine gem
32
59
  bundle add lesli_date
33
60
  ```
34
61
 
35
-
36
62
  <br />
37
- <hr/>
63
+
64
+ ## Usage
65
+
66
+ ### Format dates and times
67
+
68
+ Create a formatter from a `Date`, `DateTime`, `Time`, `TimeWithZone`, supported ISO-style string, or explicitly formatted date string:
69
+
70
+ ```ruby
71
+ datetime = LesliDate::Formatter.new(Time.current)
72
+
73
+ datetime.date.to_s
74
+ datetime.time.to_s
75
+ datetime.date_time.to_s
76
+ datetime.date_words.to_s
77
+ datetime.date_time_words.to_s
78
+ ```
79
+
80
+ Pass the input format when parsing a custom string:
81
+
82
+ ```ruby
83
+ LesliDate::Formatter
84
+ .new("2026/07/19 14:30", "%Y/%m/%d %H:%M")
85
+ .date_time
86
+ .to_s
87
+ ```
88
+
89
+ Calendar inputs retain their day and return a `Date` from `get`. Instants return
90
+ an `ActiveSupport::TimeWithZone`. Time selectors require an instant.
91
+
92
+ ```ruby
93
+ LesliDate::Formatter.new("2026-10-22").date.to_s
94
+
95
+ LesliDate::Formatter.new(
96
+ "2026-10-22 14:30",
97
+ input_zone: "America/Guatemala",
98
+ zone: "UTC"
99
+ ).date_time.to_s
100
+ ```
101
+
102
+ Offset-free date-time strings default to UTC input. Explicit offsets determine
103
+ the instant. Parsing delegates to Ruby's `DateTime.parse` and `DateTime.strptime`,
104
+ with Rails handling zone conversion. Invalid values or native parsing failures
105
+ raise `LesliDate::ParseError`, a subclass of `ArgumentError`.
106
+ See [Parsing rules](https://www.lesli.dev/gems/date/api/parsing) for details.
107
+
108
+ ### Formats and language
109
+
110
+ All selectors use their matching pattern in `Lesli.config.datetime[:formats]`,
111
+ with defaults for omitted or `nil` values. Output configuration is checked when
112
+ the formatter is constructed.
113
+
114
+ `to_s` uses the translations already loaded by Rails through `I18n.localize`.
115
+ It follows the current `I18n.locale`, or an explicit locale for one formatter:
116
+
117
+ ```ruby
118
+ LesliDate::Formatter.new(value, locale: :es).date_words.to_s
119
+ ```
120
+
121
+ LesliDate ships no translations. Add overrides in Lesli only when customization
122
+ is desired. See [Configuration](https://www.lesli.dev/gems/date/about/configuration)
123
+ for the initializer settings, defaults and native Rails localization.
124
+
125
+ ### Database compatibility
126
+
127
+ Generate adapter-compatible SQL for timestamp columns:
128
+
129
+ ```ruby
130
+ formatter = LesliDate::Formatter.new.date_time
131
+
132
+ formatter.db_timestamps
133
+ formatter.db_column("published_at", "articles")
134
+ LesliDate::Compatibility.db_now
135
+ ```
136
+
137
+ Both adapters expose `created_at_string` and `updated_at_string`. Use
138
+ `db_column(:created_at, as: false)` when grouping by an expression. Native SQL
139
+ formats and zone support differ between adapters; see
140
+ [Database expressions](https://www.lesli.dev/gems/date/api/database) for the
141
+ supported patterns, SQLite fixed-offset limits, and PostgreSQL zone conversion.
142
+
143
+ See [application examples](docs/api/examples.md) for form fields, API timestamps,
144
+ CSV imports and SQL selections. Selectors still mutate
145
+ the same formatter and return `self`; input values and configuration are not
146
+ modified.
147
+
38
148
  <br />
39
149
 
40
- ### Demo
150
+ ## Development
151
+
152
+ Clone the repository and install its dependencies:
153
+
154
+ ```shell
155
+ git clone https://github.com/LesliTech/LesliDate.git
156
+ cd LesliDate
157
+ bundle install
158
+ ```
159
+
160
+ To use local source from a Lesli development workspace, reference it from the host application's `Gemfile`:
161
+
162
+ ```ruby
163
+ gem "lesli_date", path: "gems/LesliDate"
164
+ ```
165
+
166
+ ### Tests
167
+
168
+ Run the default test task from the LesliDate directory:
169
+
170
+ ```shell
171
+ bundle exec rake
172
+ ```
41
173
 
42
- * [online demo](https://demo.lesli.dev/)
43
- * [docker demo](https://github.com/LesliTech/lesli-docker-demo)
174
+ The suite uses LesliTesting's standalone gem profile, Minitest, controlled Lesli
175
+ configuration, a fixed clock, and real SQL queries. SQLite runs in memory by
176
+ default. To execute the same suite on PostgreSQL, provide a test database URL:
44
177
 
178
+ ```shell
179
+ COVERAGE=true bundle exec rake test
180
+ LESLI_DATE_DATABASE_URL=postgresql://localhost/lesli_date_test bundle exec rake test
181
+ ```
45
182
 
46
- ### Documentation
47
- * [website](https://www.lesli.dev/)
48
- * [documentation](https://www.lesli.dev/gems/date/)
183
+ PostgreSQL tests create and clean up an isolated schema. All regressions execute
184
+ as ordinary tests, including each adapter's native formatting behavior.
49
185
 
186
+ CI uses the LesliActions gem workflow for SQLite coverage and packaging, plus
187
+ Rails 8.0/8.1 jobs that execute queries in SQLite and PostgreSQL 17.
188
+ See [Development and tests](https://www.lesli.dev/gems/date/about/development)
189
+ for setup and reproducible ordering.
50
190
 
51
- ### Connect with Lesli
191
+ <br />
52
192
 
53
- * [X: @LesliTech](https://x.com/LesliTech)
54
- * [Email: hello@lesli.tech](hello@lesli.tech)
55
- * [Website: https://www.lesli.tech](https://www.lesli.tech)
193
+ ## Documentation
194
+
195
+ - [Lesli website](https://www.lesli.dev/)
196
+ - [Documentation](https://www.lesli.dev/gems/date/)
197
+ - [Installation](https://www.lesli.dev/gems/date/about/installation)
198
+ - [Configuration](https://www.lesli.dev/gems/date/about/configuration)
199
+ - [Formatter API](https://www.lesli.dev/gems/date/api/formatter)
200
+ - [Parsing rules](https://www.lesli.dev/gems/date/api/parsing)
201
+ - [Database expressions](https://www.lesli.dev/gems/date/api/database)
202
+ - [Application examples](docs/api/examples.md)
203
+ - [Changelog](CHANGELOG.md)
204
+ - [Release notes](https://github.com/LesliTech/LesliDate/releases)
205
+ - [Issue tracker](https://github.com/LesliTech/LesliDate/issues)
206
+ - [Source code](https://github.com/LesliTech/LesliDate)
56
207
 
208
+ <br />
209
+
210
+ ## Community
211
+
212
+ - [X: @LesliTech](https://x.com/LesliTech)
213
+ - [hello@lesli.tech](mailto:hello@lesli.tech)
214
+ - [https://www.lesli.tech](https://www.lesli.tech)
215
+
216
+ <br />
217
+
218
+ ## License
57
219
 
58
- ### License
59
- -------
60
220
  Copyright (c) 2026, Lesli Technologies, S. A.
61
221
 
62
222
  This program is free software: you can redistribute it and/or modify
@@ -70,19 +230,16 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70
230
  GNU General Public License for more details.
71
231
 
72
232
  You should have received a copy of the GNU General Public License
73
- along with this program. If not, see http://www.gnu.org/licenses/.
233
+ along with this program. If not, see [https://www.gnu.org/licenses/](https://www.gnu.org/licenses/).
74
234
 
75
- <br />
76
- <hr />
77
- <br />
78
- <br />
235
+ The complete license text is available in the [license file](./license).
79
236
 
80
- <div align="center" class="has-text-centered">
81
- <img width="200" alt="Lesli logo" src="https://cdn.lesli.tech/lesli/brand/app-logo.svg" />
82
- <h3 align="center" class="mt-0">
83
- The Open-Source SaaS Development Framework for Ruby on Rails.
84
- </h3>
85
- </div>
237
+ ---
86
238
 
87
239
  <br />
88
240
  <br />
241
+
242
+ <div align="center">
243
+ <img width="80" alt="Lesli icon" src="https://cdn.lesli.tech/lesli/brand/app-icon.svg" />
244
+ <h3 align="center">The Open-Source SaaS Development Framework for Ruby on Rails.</h3>
245
+ </div>
metadata CHANGED
@@ -1,14 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ date: 2026-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '8.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.2'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '8.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: activerecord
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '8.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '8.2'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '8.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '8.2'
53
+ - !ruby/object:Gem::Dependency
54
+ name: i18n
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '1.6'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '2'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '1.6'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '2'
12
73
  description: Datetime formatter and SQL-safe utilities for Rails, part of the LesliSystem
13
74
  email:
14
75
  - hello@lesli.tech
@@ -16,20 +77,35 @@ executables: []
16
77
  extensions: []
17
78
  extra_rdoc_files: []
18
79
  files:
80
+ - CHANGELOG.md
19
81
  - Rakefile
82
+ - docs/about/configuration.md
83
+ - docs/about/development.md
84
+ - docs/about/installation.md
85
+ - docs/api/database.md
86
+ - docs/api/examples.md
87
+ - docs/api/formatter.md
88
+ - docs/api/index
89
+ - docs/api/overview.md
90
+ - docs/api/parsing.md
91
+ - docs/images/date-logo.svg
92
+ - docs/navigation
20
93
  - lib/lesli_date.rb
21
94
  - lib/lesli_date/engine.rb
95
+ - lib/lesli_date/errors.rb
22
96
  - lib/lesli_date/formatter.rb
97
+ - lib/lesli_date/parser.rb
23
98
  - lib/lesli_date/version.rb
24
99
  - license
25
100
  - readme.md
26
101
  homepage: https://www.lesli.dev/
27
102
  licenses:
28
- - GPL-3.0
103
+ - GPL-3.0-or-later
29
104
  metadata:
30
105
  homepage_uri: https://www.lesli.dev/
31
- changelog_uri: https://github.com/LesliTech/LesliDate
106
+ changelog_uri: https://github.com/LesliTech/LesliDate/blob/main/CHANGELOG.md
32
107
  source_code_uri: https://github.com/LesliTech/LesliDate
108
+ post_install_message:
33
109
  rdoc_options: []
34
110
  require_paths:
35
111
  - lib
@@ -37,14 +113,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
113
  requirements:
38
114
  - - ">="
39
115
  - !ruby/object:Gem::Version
40
- version: '2.7'
116
+ version: '3.3'
117
+ - - "<"
118
+ - !ruby/object:Gem::Version
119
+ version: '4.0'
41
120
  required_rubygems_version: !ruby/object:Gem::Requirement
42
121
  requirements:
43
122
  - - ">="
44
123
  - !ruby/object:Gem::Version
45
124
  version: '0'
46
125
  requirements: []
47
- rubygems_version: 3.7.1
126
+ rubygems_version: 3.5.16
127
+ signing_key:
48
128
  specification_version: 4
49
129
  summary: Standard Datetime Formatter for The Lesli Framework.
50
130
  test_files: []