Mailinglist Archive: yast-devel (39 mails)

< Previous Next >
Re: [yast-devel] some ruby/rails code tips
  • From: Duncan Mac-Vicar Prett <dmacvicar@xxxxxxx>
  • Date: Mon, 27 Apr 2009 18:48:07 +0200
  • Message-id: <49F5E1C7.8000408@xxxxxxx>

Some more ruby tips date parsing:

@time_string = @systemtime.currenttime.hour.to_s
@time_string << ":"
@time_string << @systemtime.currenttime.min.to_s

->

@time_string = @systemtime.currenttime.strftime("%H:%M")

The other way around is also valid, instead of manually splitting the
time, just specfy the format:

time_array = params[:currenttime].split ":"
t.currenttime = DateTime.civil(params[:year].to_i, params[:month].to_i,
params[:day].to_i, time_array[0].to_i,
time_array[1].to_i)

->

t.currenttime = DateTime.parse("#{params[:currentdate]}
#{:currenttime}", "%d/%m/%Y %H:%M")

--
Duncan Mac-Vicar P. - Engineering Manager, YaST
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)

--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
References