Hi,
I want to write a timestamp to a file, then read it in, and get a time
object again.
I’ve useusally done this with something like, epoch times
a Time.now
file.puts a.epoch
…
f = file.read
b = mktime(f)
but I can’t seem to find a native way of doing this.
is there?
db
···
–
May 16 First report on SNOBOL distributed (within BTL), 1963
May 17 24" rain in 11 hours, Pearl River, S. China, 1982
May 17 Six SLA members killed in televised gun fight, 1974
May 18 Battle of Las Piedras in Uruguay
May 18 Napoleon crowned Emperor, 1804
May 16 Discovery Day in Cayman Islands
May 17 Constitution Day in Nauru and Norway
May 18 Flag Day in Haiti
May 18 Prayer Day in Denmark
May 18 Rick Wakeman is born in West London, England, 1949
May 17* Armed Forces Day (3rd Saturday of May)
May 16* Omer 49th day
May 17* Erev Shavout
May 18* Shavuot (Festival of Weeks; 50 days after Pesach)
May 18* Yizkor
Hi all,
This worked, not as pretty as I’d liked, but…
class Time
def stamp(filename)
fh = File.open(filename,“w+”)
fh.puts “#{self.to_a.inspect}”
fh.close
end
def Time.readStamp(filename)
fh = File.open(filename)
a = eval fh.readline
mktime(*a)
end
end
a = Time.now
a.stamp(“blah”)
p Time.readStamp(“blah”)
···
On Sat, May 17, 2003 at 03:49:20AM +0900, Daniel Bretoi wrote:
Hi,
I want to write a timestamp to a file, then read it in, and get a time
object again.
I’ve useusally done this with something like, epoch times
a Time.now
file.puts a.epoch
…
f = file.read
b = mktime(f)
but I can’t seem to find a native way of doing this.
is there?
db
–
May 16 First report on SNOBOL distributed (within BTL), 1963
May 17 24" rain in 11 hours, Pearl River, S. China, 1982
May 17 Six SLA members killed in televised gun fight, 1974
May 18 Battle of Las Piedras in Uruguay
May 18 Napoleon crowned Emperor, 1804
May 16 Discovery Day in Cayman Islands
May 17 Constitution Day in Nauru and Norway
May 18 Flag Day in Haiti
May 18 Prayer Day in Denmark
May 18 Rick Wakeman is born in West London, England, 1949
May 17* Armed Forces Day (3rd Saturday of May)
May 16* Omer 49th day
May 17* Erev Shavout
May 18* Shavuot (Festival of Weeks; 50 days after Pesach)
May 18* Yizkor
–
May 16 First report on SNOBOL distributed (within BTL), 1963
May 17 24" rain in 11 hours, Pearl River, S. China, 1982
May 17 Six SLA members killed in televised gun fight, 1974
May 18 Battle of Las Piedras in Uruguay
May 18 Napoleon crowned Emperor, 1804
May 16 Discovery Day in Cayman Islands
May 17 Constitution Day in Nauru and Norway
May 18 Flag Day in Haiti
May 18 Prayer Day in Denmark
May 18 Rick Wakeman is born in West London, England, 1949
May 17* Armed Forces Day (3rd Saturday of May)
May 16* Omer 49th day
May 17* Erev Shavout
May 18* Shavuot (Festival of Weeks; 50 days after Pesach)
May 18* Yizkor
check out the parsedate module - it’s in the pickaxe.
-a
···
On Sat, 17 May 2003, Daniel Bretoi wrote:
Hi,
I want to write a timestamp to a file, then read it in, and get a time
object again.
I’ve useusally done this with something like, epoch times
a Time.now
file.puts a.epoch
…
f = file.read
b = mktime(f)
but I can’t seem to find a native way of doing this.
is there?
db
–
May 16 First report on SNOBOL distributed (within BTL), 1963
May 17 24" rain in 11 hours, Pearl River, S. China, 1982
May 17 Six SLA members killed in televised gun fight, 1974
May 18 Battle of Las Piedras in Uruguay
May 18 Napoleon crowned Emperor, 1804
May 16 Discovery Day in Cayman Islands
May 17 Constitution Day in Nauru and Norway
May 18 Flag Day in Haiti
May 18 Prayer Day in Denmark
May 18 Rick Wakeman is born in West London, England, 1949
May 17* Armed Forces Day (3rd Saturday of May)
May 16* Omer 49th day
May 17* Erev Shavout
May 18* Shavuot (Festival of Weeks; 50 days after Pesach)
May 18* Yizkor
–
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================
Hi,
I want to write a timestamp to a file, then read it in, and get a time
object again.
I often use Time#to_i and Time.at.
a = Time.now
file.puts a.to_i
b = Time.at(file.gets.to_i)
When readability is prior to simpleness, Time#to_s and
Time.parse.
a = Time.now
file.puts a
require ‘time’
b = Time.at(file.gets)
···
At Sat, 17 May 2003 03:49:20 +0900, Daniel Bretoi wrote:
–
Nobu Nakada
Sorry, this should be `Time.parse(file.gets)', of course.
···
At Sat, 17 May 2003 09:05:18 +0900, nobu.nokada@softhome.net wrote:
When readability is prior to simpleness, Time#to_s and
Time.parse.
a = Time.now
file.puts a
require ‘time’
b = Time.at(file.gets)
–
Nobu Nakada
When readability is prior to simpleness, Time#to_s and
Time.parse.
a = Time.now
file.puts a
require ‘time’
b = Time.at(file.gets)
Sorry, this should be `Time.parse(file.gets)', of course.
Hi and thank you.
Your previous worked just excellent
[~]$ irb
irb(main):001:0> a = Time.now
=> Sat May 17 16:14:42 EDT 2003
irb(main):002:0> b = a.to_i
=> 1053202482
irb(main):003:0> c = Time.at b
=> Sat May 17 16:14:42 EDT 2003
···
On Sat, May 17, 2003 at 09:12:25AM +0900, nobu.nokada@softhome.net wrote:
At Sat, 17 May 2003 09:05:18 +0900, > nobu.nokada@softhome.net wrote:
–
Nobu Nakada
–
May 17 24" rain in 11 hours, Pearl River, S. China, 1982
May 17 Six SLA members killed in televised gun fight, 1974
May 17 Constitution Day in Nauru and Norway
May 17* Armed Forces Day (3rd Saturday of May)
May 17* Erev Shavout