Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. # Ruby tips
  2.  
  3. # Rubyで時間を扱う
  4. puts "Current Time : " + time.inspect
  5. puts time.year # => Year of the date
  6. puts time.month # => Month of the date (1 to 12)
  7. puts time.day # => Day of the date (1 to 31 )
  8. puts time.wday # => 0: Day of week: 0 is Sunday
  9. puts time.yday # => 365: Day of year
  10. puts time.hour # => 23: 24-hour clock
  11. puts time.min # => 59
  12. puts time.sec # => 59
  13. puts time.usec # => 999999: microseconds
  14. puts time.zone # => "UTC": timezone name
  15.  
  16. time = Time.new
  17.  
  18. puts time.to_s
  19. # => Mon Jun 02 12:35:19 -0700 2008
  20. puts time.ctime
  21. # => Mon Jun 2 12:35:19 2008
  22. puts time.localtime
  23. # => Mon Jun 02 12:35:19 -0700 2008
  24. puts time.strftime("%Y-%m-%d %H:%M:%S")
  25. # => 2008-06-02 12:35:19
  26. # エスケープ文字一覧
  27. ### Backslash notation Hexadecimal character Description
  28.  
  29. - \a 0x07 Bell or alert
  30. - \b 0x08 Backspace
  31. - \cx Control-x
  32. - \C-x Control-x
  33. - \e 0x1b Escape
  34. - \f 0x0c Formfeed
  35. - \M-\C-x Meta-Control-x
  36. - \n 0x0a Newline
  37. - \nnn Octal notation, where n is in the range 0-7
  38. - \r 0x0d Carriage return
  39. - \s 0x20 Space
  40. - \t 0x09 Tab
  41. - \v 0x0b Vertical tab
  42. - \x Character x
  43. - \xnn Hexadecimal notation, where n is in the range 0-9, a-f, or A-F
  44. # ローカルのgemを全部アンインストールする
  45. gem uninstall -axI `gem list --no-versions | egrep -v 'test-unit|rdoc|psych|minitest|io-console|rake|bigdecimal|json'`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement