timestamp_maker 1.2.0 → 1.2.1
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/lib/timestamp_maker/video_timestamper.rb +14 -19
- 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: '045783f7b5b5a84f233d29cabecbd024978ba089878c094e4c8f3f8750f884dc'
|
4
|
+
data.tar.gz: b2225e7ff4eca4da0e87593e4ad7ab704c87d4e5a75c46c86fc191ed083b5e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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-
|
11
|
+
date: 2021-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: marcel
|