Posted By


tamuratetsuya on 03/17/09

Statistics


Viewed 783 times
Favorited by 0 user(s)

twitterのsinceの日時フォーマットの作成


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def sinceParm(d):
  2. #曜日
  3. date = decoThree(d.strftime("%A"))
  4. #日にち
  5. day = decoDay(d.strftime("%d"))
  6. #月
  7. mth = decoThree(d.strftime("%B"))
  8. #年日時
  9. ytime = d.strftime("%Y+%H %M %S")
  10. ytime = ytime.replace(' ','%3A')
  11. return date + "%2C+"+ day + "+" + mth + "+" + ytime + "+GMT"
  12.  
  13. def decoDay(day):
  14. if (day[0] == "0"):return day[1]
  15. else:return day
  16. def decoThree(string):
  17. deco = string[0]+string[1]+string[2]
  18. return deco

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.