How can I convert seconds to the format in subject.
Is there any function in Time or just need to program it?
···
--
Posted via http://www.ruby-forum.com/.
How can I convert seconds to the format in subject.
Is there any function in Time or just need to program it?
--
Posted via http://www.ruby-forum.com/.
If there's something built-in, I shouldn't have bothered with
https://github.com/ymendel/one_inch_punch/blob/master/lib/punch/core_ext/fixnum.rb
years
ago.
On Wed, Oct 10, 2012 at 10:51 AM, ajay paswan <lists@ruby-forum.com> wrote:
How can I convert seconds to the format in subject.
Is there any function in Time or just need to program it?
--
-yossef
def ptime sec
ground, sec = Time.new(2012, 1, 1, 0, 0), sec.abs
return sec.abs > 86400 ? nil : (ground + sec).strftime("%T")
end
On Wed, Oct 10, 2012 at 9:51 AM, ajay paswan <lists@ruby-forum.com> wrote:
How can I convert seconds to the format in subject.
Is there any function in Time or just need to program it?
--
Posted via http://www.ruby-forum.com/\.
Using modulo and default arguments, this can be simplified quite a bit:
def ptime sec
(Time.new(1) + sec % 86400).strftime "%T"
end
On 10/10/2012 06:00 PM, Todd Benson wrote:
def ptime sec
ground, sec = Time.new(2012, 1, 1, 0, 0), sec.abs
return sec.abs > 86400 ? nil : (ground + sec).strftime("%T")
end
--
Lars Haugseth