| 987 | } |
| 988 | |
| 989 | func FormatReadingTime(seconds int, withoutTag ...bool) string { |
| 990 | strFmt := "<span>%v</span> <small>小时</small> <span>%v</span> <small>分钟</small>" |
| 991 | if len(withoutTag) > 0 && withoutTag[0] { |
| 992 | strFmt = "%v 小时 %v 分钟" |
| 993 | } |
| 994 | hour := int(seconds / 3600) |
| 995 | second := int(seconds % 3600 / 60) |
| 996 | secondStr := strconv.Itoa(second) |
| 997 | if second < 10 { |
| 998 | secondStr = "0" + secondStr |
| 999 | } |
| 1000 | return fmt.Sprintf(strFmt, hour, secondStr) |
| 1001 | } |
| 1002 | |
| 1003 | // 拆分markdown |
| 1004 | func SplitMarkdown(segSharp, markdown string) (markdowns []string) { |