timestamp_maker 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42381622c6bc152ee1ca0d7b69e37de3694e2bc656f2364523eee7e0f61b8027
4
- data.tar.gz: 38649f363088143afdb178ddacfac05ed617b53af2c1d685ecb24f75e416212d
3
+ metadata.gz: '045783f7b5b5a84f233d29cabecbd024978ba089878c094e4c8f3f8750f884dc'
4
+ data.tar.gz: b2225e7ff4eca4da0e87593e4ad7ab704c87d4e5a75c46c86fc191ed083b5e69
5
5
  SHA512:
6
- metadata.gz: 3822ff2a0ef886a63b61d075f88899fcb5636be686323212c6636afc817e4ccc66f4c0436e424fe06d8a73e1da7bcc983ef0a44f76be75cf8ccdcb81b15b69aa
7
- data.tar.gz: 7b8de123fc936bb49c10fcd4f6cad59ba954d6ad7e6f6272109b71249447284fd9d44f9f58899a0cce7d8d5ee0f03cafead1c89672cc32ecb88b38cff03578f6
6
+ metadata.gz: 9af1f4d12c9f92f6b08678966c4ff4f722706f2b9f633aaa739154399380090c28cff6d6fa3d8c126d5989e9b986c0e94c67c4aeae52d92b73976a6afe380f37
7
+ data.tar.gz: b015042b64a96b483db3c2f16e3f5f236b33150cbddced62c845703ce644ad76b88dba3d87167ed264192b5e6d520211e37fcb1f379ca1ee088e9db89af58c8d
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'time'
5
5
  require 'open3'
6
6
  require 'English'
7
+ require 'tzinfo'
7
8
 
8
9
  module TimestampMaker
9
10
  module VideoTimestamper
@@ -43,25 +44,7 @@ module TimestampMaker
43
44
  #{output_path}
44
45
  ]
45
46
 
46
- tz =
47
- case time.zone
48
- when TZInfo::Timezone then time.zone.name
49
- when String
50
- begin
51
- TZInfo::Timezone.get(time.zone).name
52
- rescue TZInfo::InvalidTimezoneIdentifier
53
- time.strftime('%::z').then do |string|
54
- sign =
55
- case string[0]
56
- when '+' then '-'
57
- when '-' then '+'
58
- else raise "Cannot parse time zone: #{string}"
59
- end
60
- "#{sign}#{string[1..-1]}"
61
- end
62
- end
63
- else raise TypeError
64
- end
47
+ tz = tz_env_string(time)
65
48
  raise "Command failed with exit #{$CHILD_STATUS.exitstatus}: #{command.first}" unless system({ 'TZ' => tz }, *command)
66
49
  end
67
50
 
@@ -83,6 +66,18 @@ module TimestampMaker
83
66
 
84
67
  private
85
68
 
69
+ def tz_env_string(time)
70
+ return time.zone.name if time.zone.is_a? TZInfo::Timezone
71
+
72
+ TZInfo::Timezone.get(time.zone).name
73
+ rescue TZInfo::InvalidTimezoneIdentifier
74
+ offset = time.utc_offset
75
+ tz_string = "#{offset / 3600}:#{offset % 3600 / 16}:#{offset % 60}"
76
+ return "+#{tz_string}" if offset.negative?
77
+
78
+ "-#{tz_string}"
79
+ end
80
+
86
81
  def coord_map(coordinate_origin, x, y)
87
82
  case coordinate_origin
88
83
  when 'top-left' then "x=#{x}:y=#{y}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timestamp_maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weihang Jian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-19 00:00:00.000000000 Z
11
+ date: 2021-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: marcel