to_timezone 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce7a7bdd54ede5840cab4ba15cb9053edd65593a3fc201d01c3f68299cf789f9
4
- data.tar.gz: 489e4184cdfe88291004d7fc6ab1426214b8a3b477f6f273d25d698dc9d28967
3
+ metadata.gz: 350303dbe86ebf35940bf3d1106bf667294ed5b2dc9a8a37ed17fdd9b0bf3edb
4
+ data.tar.gz: 7df68e120ca9ae4860721d280b3d63bb1858e6ae338716bfad4401061b9359f1
5
5
  SHA512:
6
- metadata.gz: 77504136e3e7d7b16aa116692d27a370d399a29650682a9fb335e038ee2cb00b142a192d8b5aceede385d1e7cceed12e2ac8db6cfbbe1bc5a75512b0d1303608
7
- data.tar.gz: b8e83de1f21d4c4846715dbbd186f0c9ee6cbda04e59be54e1725e51652ef3560dda2149e0633bd1ac04eecb18a52869be36b393f61526d3915488c4d6b75222
6
+ metadata.gz: '091de63eb19ea8be48064261655fd624e4ad1ccdd729cccc8006fab217b0ce4c91d01c188a97a63ab6d2eeccfbfe84ad74570cd59df7836aa009fc9f9a36f549'
7
+ data.tar.gz: 63d08861e11394b95cd63ab3d3a868300212792669344b59341c4ac48aa2840f7b3d07d0cb9c4a62628e551fdad261bbc44c608a86e57934dd47345de9207794
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
@@ -1,38 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'tzs'
4
- require 'active_support'
5
- require 'active_support/core_ext/time'
4
+ require 'active_support/time'
6
5
  require 'active_support/core_ext/string/zones'
7
6
 
8
7
  module ToTimezone
8
+ # For Time, String, and ActiveSupport::TimeWithZone — all support in_time_zone directly.
9
9
  module TzExt
10
10
  ToTimezone::Tzs::TIMEZONES.each do |abbr, timezone|
11
- define_method("to_#{abbr}") do
12
- if is_a?(DateTime)
13
- to_time.in_time_zone(timezone)
14
- else
15
- in_time_zone(timezone)
16
- end
17
- end
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) }
18
19
  end
19
20
  end
20
21
  end
21
22
 
22
- # Extend Time and DateTime
23
23
  class Time
24
24
  include ToTimezone::TzExt
25
25
  end
26
26
 
27
27
  class DateTime
28
- include ToTimezone::TzExt
28
+ include ToTimezone::TzExtDateTime
29
29
  end
30
30
 
31
31
  class String
32
32
  include ToTimezone::TzExt
33
33
  end
34
34
 
35
- # Explicitly patch ActiveSupport::TimeWithZone
36
35
  if defined?(ActiveSupport::TimeWithZone)
37
36
  class ActiveSupport::TimeWithZone
38
37
  include ToTimezone::TzExt
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ToTimezone
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_timezone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nujian Den Mark Meralpis
@@ -72,14 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 2.5.0
75
+ version: 2.7.0
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.7.1
82
+ rubygems_version: 4.0.10
83
83
  specification_version: 4
84
84
  summary: Seamlessly convert Time and DateTime objects to different time zones with
85
85
  intuitive methods like `.to_pht`, `.to_ict`, and more.