qtime 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/qtime.rb +49 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a92b3ed0c894eb310cd48a3a6806706578a51184
4
+ data.tar.gz: bf039b99bfc612c1941d86a41869a14923746071
5
+ SHA512:
6
+ metadata.gz: cb82c4582774b8bdcbd61edb15936ed0a351c13a5d805cd4a564bc3d39730c7cf06f2cd13b66e76d6daf58749291babc41c4a56b9926d138f1cb692858354a61
7
+ data.tar.gz: e2b2916a6dfb0b1ecefa50f8c5f5fdbd812cd3fc130b7a4a991afb8283a40b8eff3aba03c5b9bd48c8176011aea682415c6ea1b7d9a13e425880d2f6db4c0957
data/lib/qtime.rb ADDED
@@ -0,0 +1,49 @@
1
+ require "time"
2
+ require "date"
3
+
4
+ class Numeric
5
+ def days
6
+ (self.to_f * 86400).to_i
7
+ end
8
+ end
9
+
10
+ class Qtime
11
+ class << self
12
+ def sub(time1, time2)
13
+ if time1.is_a?(Time) and time2.is_a?(Time)
14
+ sub = time1.to_i - time2.to_i
15
+ if sub >0
16
+ return time1.to_i - time2.to_i
17
+ else
18
+ raise "parameter 1 is bigger than parameter 2, the sub is #{sub}"
19
+ end
20
+ else
21
+ raise "wrong arguments type, it is need Time"
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ class Time
28
+ def -(days)
29
+ Time.at(self.to_i - days)
30
+ end
31
+
32
+ def normal_parse
33
+ self.strftime("%Y-%m-%d %H:%S:%M")
34
+ end
35
+
36
+ def to_day(separator="")
37
+ case separator
38
+ when "line"
39
+ self.strftime("%Y-%m-%d")
40
+ when "solidus"
41
+ self.strftime("%Y/%m/%d")
42
+ else
43
+ self.strftime("%Y%m%d")
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ p Time.new.to_day
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qtime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike.Gao
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem for extesion time and date class
14
+ email: mike.gao0611@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/qtime.rb
20
+ homepage: https://github.com/mikegao/qtime
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: extesion time and date classs
44
+ test_files: []