feidee_utils 0.0.4.5 → 0.0.4.6

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
  SHA1:
3
- metadata.gz: 25f4aacc8498733f8711c5d64df58d9585127787
4
- data.tar.gz: dad19bf406c330c56c34c0b5f1a22d2d26ab401f
3
+ metadata.gz: cdc81f2ed8b63e0e750f6b53dac1bc925eb3b509
4
+ data.tar.gz: 25397ff7b32f52165c711ba6789d7393889257af
5
5
  SHA512:
6
- metadata.gz: 04e3f08c178d793c83a6c40baf435a065493f819dd2a74c1a85a359c4e41e0fc1be118dad36054a37df1e45bc15138882a0beecafe4523082fd9a988daf4509b
7
- data.tar.gz: 79d9ac9988647d19e02ed3416e4f9fefc2f8d79ffce73e3dbc07f388e886f74062d7c23ceeefe1c31b31aa8a39801b47538053fd94627f313774e4d9c7b35e84
6
+ metadata.gz: 995ecd1e223cf972c5a6724ebb5117dc5a9e1c621f5902a628b3a592f62d925acfdf9b9881235d47741d46c3bff28dd2416b319c2208016624759ed33b4bf746
7
+ data.tar.gz: ce41000745f1d36772dd4bfaf2d7a2f2ac881b8adc09338f3023e6ba93a8e95464b6f8b7c55bc4e600a71fb95ed57891568c4939a2560b63002c5e8cda37ffbb
@@ -1,9 +1,23 @@
1
+ require 'tzinfo'
2
+
1
3
  module FeideeUtils
2
4
  class Record
3
5
  module Utils
6
+ # Feidee assumes all users are in China and uses China Standard Time.
7
+ # It gets a local time, e.g. 2017-12-09 11:30 DST and treats it as
8
+ # 2017-12-09 11:30 CST, then convert it to UTC time 2017-12-09 03:30 UTC.
9
+ # Timestamp stored in database is the UTC time.
10
+ AssumedTimezone = TZInfo::Timezone.get("Asia/Shanghai")
11
+
4
12
  protected
13
+ # To get the local time, first we convert timestamp to UTC time
14
+ # 2017-12-09 03:00 UTC, then get the corresponding time in
15
+ # AssumedTimezone.
16
+ # Note utc_to_local() would return 2017-12-09 11:30 UTC, of which the
17
+ # timezone is different from physical timezone CST. The actual timezone
18
+ # has been lost when the timestamp was written to database.
5
19
  def timestamp_to_time num
6
- Time.at(num / 1000.0, num % 1000)
20
+ AssumedTimezone.utc_to_local(Time.at(num / 1000.0, num % 1000).utc)
7
21
  end
8
22
 
9
23
  def to_bigdecimal number
@@ -1,3 +1,3 @@
1
1
  module FeideeUtils
2
- VERSION = '0.0.4.5'
2
+ VERSION = '0.0.4.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feidee_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.5
4
+ version: 0.0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liqing Muyi
@@ -70,6 +70,26 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 1.3.10
73
+ - !ruby/object:Gem::Dependency
74
+ name: tzinfo
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '1.2'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.2.2
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.2.2
73
93
  - !ruby/object:Gem::Dependency
74
94
  name: minitest
75
95
  requirement: !ruby/object:Gem::Requirement