Class: Datetimetools

Inherits:
Object
  • Object
show all
Defined in:
lib/datetimetools.rb

Class Method Summary collapse

Class Method Details

.get_date_time(type) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/datetimetools.rb', line 8

def self.get_date_time(type)
    today = Time.new;
  case type
     when 0
       then return today.strftime("%Y%m%d%H%M%S")
      when 1
         then return today.strftime("%Y年%m月%d日 %H时%M分%S秒")
      when 2
         then return today.strftime("%Y%m%d")
      when 3
         then return today.strftime("%Y年%m月%d日")
      when 4
         then return today.strftime("%H%M%S")
      when 5
         then return today.strftime("%H时%M分%S秒")
      when 6
         then return today.strftime("%Y%m%d_%H%M")
      when 7
         then return today.strftime("%m%d_%H%M")
      when 8
         then return today.strftime("%D")
      when 9
         then return today.strftime("%Y-%m-%d %H:%M:%S %A")
      when 10
         then return today.strftime("%Y-%m-%d %H:%M:%S 第%U个%a")
      else
         return today.strftime("%Y%m%d%H%M%S")
  end
end

.testObject



4
5
6
# File 'lib/datetimetools.rb', line 4

def self.test  
  puts "Hello Best Fei!"  
end