add mcp (Model Context Protocol) support

This commit is contained in:
MaysWind
2025-07-06 03:02:19 +08:00
parent 620ccf317f
commit 8dce0f2d6a
32 changed files with 1379 additions and 20 deletions
+32 -9
View File
@@ -9,15 +9,16 @@ import (
)
const (
longDateFormat = "2006-01-02"
longDateTimeFormat = "2006-01-02 15:04:05"
longDateTimeWithTimezoneFormat = "2006-01-02 15:04:05Z07:00"
longDateTimeWithTimezoneFormat2 = "2006-01-02 15:04:05 Z0700"
longDateTimeWithoutSecondFormat = "2006-01-02 15:04"
shortDateTimeFormat = "2006-1-2 15:4:5"
yearMonthDateTimeFormat = "2006-01"
westernmostTimezoneUtcOffset = -720 // Etc/GMT+12 (UTC-12:00)
easternmostTimezoneUtcOffset = 840 // Pacific/Kiritimati (UTC+14:00)
longDateFormat = "2006-01-02"
longDateTimeFormat = "2006-01-02 15:04:05"
longDateTimeWithTimezoneFormat = "2006-01-02 15:04:05Z07:00"
longDateTimeWithTimezoneFormat2 = "2006-01-02 15:04:05 Z0700"
longDateTimeWithTimezoneRFC3389Format = "2006-01-02T15:04:05Z07:00"
longDateTimeWithoutSecondFormat = "2006-01-02 15:04"
shortDateTimeFormat = "2006-1-2 15:4:5"
yearMonthDateTimeFormat = "2006-01"
westernmostTimezoneUtcOffset = -720 // Etc/GMT+12 (UTC-12:00)
easternmostTimezoneUtcOffset = 840 // Pacific/Kiritimati (UTC+14:00)
)
// ParseNumericYearMonth returns numeric year and month from textual content
@@ -65,6 +66,28 @@ func FormatUnixTimeToLongDateTime(unixTime int64, timezone *time.Location) strin
return t.Format(longDateTimeFormat)
}
// FormatUnixTimeToLongDateTimeWithTimezone returns a textual representation of the unix time formatted by long date time with timezone format
func FormatUnixTimeToLongDateTimeWithTimezone(unixTime int64, timezone *time.Location) string {
t := parseFromUnixTime(unixTime)
if timezone != nil {
t = t.In(timezone)
}
return t.Format(longDateTimeWithTimezoneFormat)
}
// FormatUnixTimeToLongDateTimeWithTimezoneRFC3389Format returns a textual representation of the unix time formatted by long date time with timezone RFC 3389 format
func FormatUnixTimeToLongDateTimeWithTimezoneRFC3389Format(unixTime int64, timezone *time.Location) string {
t := parseFromUnixTime(unixTime)
if timezone != nil {
t = t.In(timezone)
}
return t.Format(longDateTimeWithTimezoneRFC3389Format)
}
func FormatYearMonthDayToLongDateTime(year string, month string, day string) (string, error) {
if len(year) == 2 {
yearLast2Digits, err := StringToInt(year)