timetoday 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/timetoday.rb +23 -0
  2. metadata +56 -0
data/lib/timetoday.rb ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # file: timetoday.rb
3
+
4
+ require 'date'
5
+
6
+ class TimeToday
7
+
8
+ def self.any()
9
+ #seconds_in_day = (DateTime.now + 1).to_time - DateTime.now.to_time
10
+ seconds_in_day = 86399.999461942 # result from above
11
+
12
+ any_time = Time.at rand(seconds_in_day)
13
+ day, mon, year = Time.now.to_a.values_at 3,4,5
14
+ s, min, hr = any_time.to_a.values_at 0,1,2
15
+ Time.new(year, mon, day, hr, min, s)
16
+ end
17
+
18
+ def self.future()
19
+ t = Time.now
20
+ time_remaining = ((Time.now.to_date + 1).to_time - 1) - t
21
+ t + rand(time_remaining)
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timetoday
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
+ platform: ruby
7
+ authors:
8
+ - James Robertson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-22 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email:
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/timetoday.rb
27
+ has_rdoc: true
28
+ homepage:
29
+ licenses: []
30
+
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.5.2
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: timetoday
55
+ test_files: []
56
+