Word to the wise: These gems have been tested, but are not battle-hardened. If you’re thinking of using NMatrix (or other SciRuby components) to write mission critical code, such as for a self-driving car or controlling an ARKYD 100 satellite, you should expect to encounter a few bugs — and be prepared for them.
Ruby作为一种通用的程序设计语言,和其它常用的编程语言一样,可以编写大部分我们日常遇到的任务,而且完成得更简单优雅。已经有人用她编写了Web服务器程序、科学计算程序、视频游戏软件和其他有趣的应用。更多的人用她来做程序原形实验和处理每天遇到的各种琐碎的编程任务,基本上就能做这些事情希望能帮到你,当然它的功能还有很多我写了个程序 你看一下 不明白的话联系我 有注释#获取当前的时间
today = Time.new
puts "当前日期:" + today.strftime("%Y-%m-%d %H:%M:%S")#采用格式化输出
#获取指定日期的时间 如 2010-08-30 20:50:01
day = Time.local(2010, 8 , 30 , 20, 50, 1)
puts "指定日期:" + day.strftime("%Y-%m-%d %H:%M:%S")
#获取指定日期的秒数(就是1970年到指定日期的秒数)
sec1 = day.to_i
#同理,获取今天的秒数
sec2 = today.to_i
#秒数求差,同时折合为天数
num = (sec1 - sec2)/(24*60*60)
puts (day.strftime("%Y-%m-%d %H:%M:%S") + "与" + today.strftime("%Y-%m-%d %H:%M:%S") + "相差" + num.to_s + "天")