String 获取两个时间相差
()
| 42 | |
| 43 | // String 获取两个时间相差 |
| 44 | func (h *Holiday) String() string { |
| 45 | d := time.Until(h.date) |
| 46 | switch { |
| 47 | case d >= 0: |
| 48 | return "距离" + h.name + "还有: " + strconv.FormatFloat(d.Hours()/24.0, 'f', 2, 64) + "天!" |
| 49 | case d+h.dur >= 0: |
| 50 | return "好好享受 " + h.name + " 假期吧!" |
| 51 | default: |
| 52 | return "今年 " + h.name + " 假期已过" |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func weekend() string { |
| 57 | t := time.Now().Weekday() |
no outgoing calls
no test coverage detected