to_timezone 0.1.0 → 0.2.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/README.md +6 -0
- data/lib/to_timezone/tz_ext.rb +12 -3
- data/lib/to_timezone/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf5ed67a393994dcafa41ea4d984728da78bc35acd37bdf3032eb080a01c1f97
|
4
|
+
data.tar.gz: 627a7d52a8a598bb2480f2773815eaa7d2f65efe7b147cd5bed839cad0b0a08c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24714e7ab22dd31ac88c903170cd60baab754c7a0cc07e76c14cb32a879242ab9f9c19a0348d25fd19812e7a665463c4a7293f3ef796505e49776a3d3b057b2d
|
7
|
+
data.tar.gz: f6a191e2ff227b528adc5f62b6c75763b63f12ea5168c0da243dc87101db4601b97775bbccba2b61355fbf4b6daa382b5a8b317092718335f0db2241e150ff6b
|
data/README.md
CHANGED
@@ -38,6 +38,12 @@ manila_time = current_time.to_pht # => Asia/Manila time zone
|
|
38
38
|
puts manila_time # => 2025-02-07 10:53:47.355858000 PST +08:00
|
39
39
|
```
|
40
40
|
|
41
|
+
or with Strings:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
pht = "2014-07-05 14:30:00".to_ph
|
45
|
+
puts pht # => 2014-07-05 14:30:00 +08:00
|
46
|
+
```
|
41
47
|
### Supported Timezones:
|
42
48
|
|
43
49
|
| Method | Timezone Name |
|
data/lib/to_timezone/tz_ext.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require
|
3
|
+
require_relative "tzs"
|
4
|
+
require "active_support/core_ext/time"
|
5
|
+
require "active_support/core_ext/string/zones"
|
5
6
|
|
6
7
|
module ToTimezone
|
7
8
|
module TzExt
|
8
9
|
ToTimezone::Tzs::TIMEZONES.each do |abbr, timezone|
|
9
10
|
define_method("to_#{abbr}") do
|
10
|
-
|
11
|
+
utc.in_time_zone(timezone)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -22,6 +23,14 @@ class DateTime
|
|
22
23
|
include ToTimezone::TzExt
|
23
24
|
end
|
24
25
|
|
26
|
+
class String
|
27
|
+
include ToTimezone::TzExt
|
28
|
+
|
29
|
+
def utc
|
30
|
+
in_time_zone("UTC")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
# Explicitly patch ActiveSupport::TimeWithZone
|
26
35
|
if defined?(ActiveSupport::TimeWithZone)
|
27
36
|
class ActiveSupport::TimeWithZone
|
data/lib/to_timezone/version.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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nujian Den Mark Meralpis
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|