235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/greenpepper/converter.rb', line 235
def self.format
Proc.new{ |d,expected_format|
date_base_slash = d.year.to_s.rjust(4,"0") + "-" +
d.month.to_s.rjust(2,"0") + "-" + d.day.to_s.rjust(2,"0")
date_base_frontslash = d.year.to_s.rjust(4,"0") + "/" +
d.month.to_s.rjust(2,"0") + "/" + d.day.to_s.rjust(2,"0")
date_hour_min = d.hour.to_s.rjust(2,"0") + ":" +
d.min.to_s.rjust(2,"0")
date_extension = "Z"
case expected_format
when /^(\d+)\-(\d+)\-(\d+)\w(\d+):(\d+)\w$/
date_base_slash + "T" + date_hour_min + date_extension
when /^(\d+)\-(\d+)\-(\d+)\s(\d+):(\d+)$/
date_base_slash + " " + date_hour_min
when /^(\d+)\-(\d+)\-(\d+)\s(\d+):(\d+)\w$/
date_base_slash + " " + date_hour_min + date_extension
when /^(\d+)\-(\d+)\-(\d+)$/
date_base_slash
when /^(\d+)\/(\d+)\/(\d+)\w(\d+):(\d+)\w$/
date_base_frontslash + "T" + date_hour_min + date_extension
when /^(\d+)\/(\d+)\/(\d+)\s(\d+):(\d+)$/
date_base_frontslash + " " + date_hour_min
when /^(\d+)\/(\d+)\/(\d+)\s(\d+):(\d+)\w$/
date_base_frontslash + " " + date_hour_min + date_extension
when /^(\d+)\/(\d+)\/(\d+)$/
date_base_frontslash
else
d.to_s
end
}
end
|