// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package timeutil
import (
"fmt"
"html"
"html/template"
)
// DateTime renders an absolute time HTML given a time as a string
func DateTime(format, datetime, fallback string) template.HTML {
datetimeEscaped := html.EscapeString(datetime)
fallbackEscaped := html.EscapeString(fallback)
switch format {
case "short":
return template.HTML(fmt.Sprintf(`%s`, datetimeEscaped, fallbackEscaped))
case "long":
return template.HTML(fmt.Sprintf(`%s`, datetimeEscaped, fallbackEscaped))
case "full":
return template.HTML(fmt.Sprintf(`%s`, datetimeEscaped, fallbackEscaped))
}
return template.HTML("error in DateTime")
}