to_timezone 0.2.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +19 -1
- data/CHANGELOG.md +53 -0
- data/Rakefile +3 -3
- data/lib/to_timezone/tz_ext.rb +13 -13
- data/lib/to_timezone/version.rb +1 -1
- data/lib/to_timezone.rb +2 -2
- metadata +4 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 350303dbe86ebf35940bf3d1106bf667294ed5b2dc9a8a37ed17fdd9b0bf3edb
|
|
4
|
+
data.tar.gz: 7df68e120ca9ae4860721d280b3d63bb1858e6ae338716bfad4401061b9359f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '091de63eb19ea8be48064261655fd624e4ad1ccdd729cccc8006fab217b0ce4c91d01c188a97a63ab6d2eeccfbfe84ad74570cd59df7836aa009fc9f9a36f549'
|
|
7
|
+
data.tar.gz: 63d08861e11394b95cd63ab3d3a868300212792669344b59341c4ac48aa2840f7b3d07d0cb9c4a62628e551fdad261bbc44c608a86e57934dd47345de9207794
|
data/.rubocop.yml
CHANGED
|
@@ -2,7 +2,25 @@ AllCops:
|
|
|
2
2
|
TargetRubyVersion: 3.1
|
|
3
3
|
|
|
4
4
|
Style/StringLiterals:
|
|
5
|
-
EnforcedStyle:
|
|
5
|
+
EnforcedStyle: single_quotes
|
|
6
6
|
|
|
7
7
|
Style/StringLiteralsInInterpolation:
|
|
8
8
|
EnforcedStyle: double_quotes
|
|
9
|
+
|
|
10
|
+
Layout/LineLength:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
Naming/VariableNumber:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
Gemspec/RequiredRubyVersion:
|
|
17
|
+
Enabled: false
|
|
18
|
+
|
|
19
|
+
Style/ClassAndModuleChildren:
|
|
20
|
+
Enabled: false
|
|
21
|
+
|
|
22
|
+
Style/Documentation:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
Metrics/ClassLength:
|
|
26
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
1
8
|
## [Unreleased]
|
|
2
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
- Split `TzExt` into two modules — `TzExt` (Time, String, ActiveSupport::TimeWithZone) and `TzExtDateTime` (DateTime) — eliminating the `is_a?(DateTime)` runtime branch from every method call
|
|
12
|
+
- Replaced `require 'active_support'` + `require 'active_support/core_ext/time'` with the targeted `require 'active_support/time'`, reducing load overhead in standalone (non-Rails) usage
|
|
13
|
+
- Method names in `define_method` now use symbols (`:"to_#{abbr}"`) instead of strings, skipping the string-to-symbol intern step at load time
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- Minimum Ruby version raised from `2.5.0` to `2.7.0`; Ruby 2.5 and 2.6 reached end-of-life in March 2021 and March 2022 respectively
|
|
17
|
+
|
|
18
|
+
## [0.4.0] - 2026-06-26
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Updated gem dependencies
|
|
22
|
+
- Improved timezone conversion methods in `TzExt` module
|
|
23
|
+
- Added `ActiveSupport::TimeWithZone` support via conditional include
|
|
24
|
+
|
|
25
|
+
## [0.3.0] - 2025-08-19
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- `tzdata` added as a CI dependency for reliable timezone support across environments
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
- Removed automated release job from CI configuration
|
|
32
|
+
|
|
33
|
+
## [0.2.4] - 2025-08-19
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Refactored timezone conversion methods for `DateTime` and `String` classes
|
|
37
|
+
- Resolved RuboCop offenses across the codebase
|
|
38
|
+
|
|
39
|
+
## [0.2.3] - 2025-08-19
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
- CI workflow for automated testing and gem releasing
|
|
43
|
+
|
|
44
|
+
### Removed
|
|
45
|
+
- Removed `timecop` as a development dependency
|
|
46
|
+
|
|
47
|
+
## [0.2.0] - 2025-02-26
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
- String support: timezone conversion methods can now be called directly on time strings (e.g. `"2025-02-07 07:00:00 +0800".to_utc`)
|
|
51
|
+
- Added `active_support/core_ext/string/zones` to support `String#in_time_zone`
|
|
52
|
+
|
|
3
53
|
## [0.1.0] - 2025-02-07
|
|
4
54
|
|
|
55
|
+
### Added
|
|
5
56
|
- Initial release
|
|
57
|
+
- Timezone conversion methods (`to_pht`, `to_utc`, `to_ict`, etc.) for `Time` and `DateTime`
|
|
58
|
+
- 150+ timezone abbreviation aliases backed by IANA timezone identifiers
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
5
|
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
|
7
7
|
|
|
8
|
-
require
|
|
8
|
+
require 'rubocop/rake_task'
|
|
9
9
|
|
|
10
10
|
RuboCop::RakeTask.new
|
|
11
11
|
|
data/lib/to_timezone/tz_ext.rb
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require_relative 'tzs'
|
|
4
|
+
require 'active_support/time'
|
|
5
|
+
require 'active_support/core_ext/string/zones'
|
|
6
6
|
|
|
7
7
|
module ToTimezone
|
|
8
|
+
# For Time, String, and ActiveSupport::TimeWithZone — all support in_time_zone directly.
|
|
8
9
|
module TzExt
|
|
9
10
|
ToTimezone::Tzs::TIMEZONES.each do |abbr, timezone|
|
|
10
|
-
define_method("to_#{abbr}")
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
define_method(:"to_#{abbr}") { in_time_zone(timezone) }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# DateTime#in_time_zone requires a prior to_time conversion.
|
|
16
|
+
module TzExtDateTime
|
|
17
|
+
ToTimezone::Tzs::TIMEZONES.each do |abbr, timezone|
|
|
18
|
+
define_method(:"to_#{abbr}") { to_time.in_time_zone(timezone) }
|
|
13
19
|
end
|
|
14
20
|
end
|
|
15
21
|
end
|
|
16
22
|
|
|
17
|
-
# Extend Time and DateTime
|
|
18
23
|
class Time
|
|
19
24
|
include ToTimezone::TzExt
|
|
20
25
|
end
|
|
21
26
|
|
|
22
27
|
class DateTime
|
|
23
|
-
include ToTimezone::
|
|
28
|
+
include ToTimezone::TzExtDateTime
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
class String
|
|
27
32
|
include ToTimezone::TzExt
|
|
28
|
-
|
|
29
|
-
def utc
|
|
30
|
-
in_time_zone("UTC")
|
|
31
|
-
end
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
# Explicitly patch ActiveSupport::TimeWithZone
|
|
35
35
|
if defined?(ActiveSupport::TimeWithZone)
|
|
36
36
|
class ActiveSupport::TimeWithZone
|
|
37
37
|
include ToTimezone::TzExt
|
data/lib/to_timezone/version.rb
CHANGED
data/lib/to_timezone.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: to_timezone
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nujian Den Mark Meralpis
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -37,20 +37,6 @@ dependencies:
|
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: timecop
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0'
|
|
47
|
-
type: :development
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
54
40
|
description: Adds intuitive time zone conversion methods to Time and DateTime in Rails,
|
|
55
41
|
allowing calls like `.to_pht`, `.to_ict`, and more for effortless time zone handling.
|
|
56
42
|
email:
|
|
@@ -86,14 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
86
72
|
requirements:
|
|
87
73
|
- - ">="
|
|
88
74
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 2.
|
|
75
|
+
version: 2.7.0
|
|
90
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
77
|
requirements:
|
|
92
78
|
- - ">="
|
|
93
79
|
- !ruby/object:Gem::Version
|
|
94
80
|
version: '0'
|
|
95
81
|
requirements: []
|
|
96
|
-
rubygems_version:
|
|
82
|
+
rubygems_version: 4.0.10
|
|
97
83
|
specification_version: 4
|
|
98
84
|
summary: Seamlessly convert Time and DateTime objects to different time zones with
|
|
99
85
|
intuitive methods like `.to_pht`, `.to_ict`, and more.
|