顯示具有 time 標籤的文章。 顯示所有文章
顯示具有 time 標籤的文章。 顯示所有文章

2009年2月2日 星期一

Time,Date

time api

2008年12月9日 星期二

default,time,format

Set the default date format for your Rails application
修改 Ruby 預設的 Time 顯示格式

2008年8月21日 星期四

time range conditions

Record.find(:all, :conditions => {:todo_time => Time.now.ago(10.days)..Time.now})

Time db

Time#to_s(:db) ignores Time#zone -- example:

>> Time.mktime(2008, 06, 20, 0, 31, 7).to_s(:db)
=> "2008-06-20 00:31:07"
>> Time.utc(2008, 06, 20, 0, 31, 7).to_s(:db)
=> "2008-06-20 00:31:07"

2008年7月17日 星期四

Time, 想把秒數直接弄成幾天幾分幾秒

#at 從1970年1月1日後 幾秒鐘的時間
#at 直接拿到的是local time, 還要用getgm換成gmtime 就可以了
>> Time.at(10000).getgm
=> Thu Jan 01 02:46:40 UTC 1970


>> Time.gm(2000)
=> Sat Jan 01 00:00:00 UTC 2000
>> Time.mktime(2000)
=> Sat Jan 01 00:00:00 +0800 2000
>> Time.mktime(2000).getgm
=> Fri Dec 31 16:00:00 UTC 1999

2008年6月9日 星期一

string, to_time, parse

想把字串變成time object

>> ('2004/01/2').to_time
=> Fri Jan 02 00:00:00 UTC 2004 <<= 有UTC

>> Time.parse('2004/01/2')
=> Fri Jan 02 00:00:00 +0800 2004

2008年5月18日 星期日

time, setTimeout, setInterval, fadeOut, callback, 跑馬燈

  1. 自己用setTimeout 做interval 比較好, 爆掉一次就讓他爆掉, 別用setInterval錯了還一直跑,利用 setTimeout 自己call 自己
  2. fadeOut後, 才做替換html的hide動作, 需要將他放到callback 裡, 不然html hide和fadeOut是同步的這樣會直接看到消失而已
  3. 可以將跑馬燈需要的option 藏起來, 像這樣藏在hidden_forum裡, 用size()可以知道裡面包含幾個

<div id='hidden_forum' style='display:none'>
<div>abc</div>
<div>def</div>
</div>

<script type="text/javascript">
var index = 0;
var shuffler;
var news;
var max_news;

function replace_news(){
index = index % max_news
news = $('#hidden_forum div:eq('+index+')').clone();
shuffler.fadeOut('slow', function() {shuffler.html(news.html()).hide().fadeIn('slow') });
index++;
if(max_news > 1) { var dummy = setTimeout(replace_news, 5000); }
}

$(function(){
max_news = $('#hidden_forum div').size();

if(max_news > 0){
shuffler = $('div.news div');
replace_news();
}
});
</script>