Class: ConvertTime
- Inherits:
-
Object
- Object
- ConvertTime
- Defined in:
- lib/convert_time.rb
Class Method Summary collapse
Class Method Details
.convert(date) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/convert_time.rb', line 6 def convert(date) type = date.class if date && type != Date && (type == DateTime || type == Time) weeks = date.to_date elsif type == Date weeks = date else return '参数非法' end ConvertTime.convert_to_week(weeks) end |
.convert_to_week(weeks) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/convert_time.rb', line 18 def convert_to_week(weeks) week = weeks.strftime("%A") case week when 'Monday' return '星期一' when 'Tuesday' return '星期二' when 'Wednesday' return '星期三' when 'Thursday' return '星期四' when 'Friday' return '星期五' when 'Saturday' return '星期六' when 'Sunday' return '星期天' else return '参数非法' end end |