MCPcopy Create free account
hub / github.com/github/gh-aw / formatTimeValue

Function formatTimeValue

pkg/console/render.go:502–517  ·  view source on GitHub ↗

formatTimeValue formats a time.Time reflect value as a display string.

(val reflect.Value)

Source from the content-addressed store, hash-verified

500
501// formatTimeValue formats a time.Time reflect value as a display string.
502func formatTimeValue(val reflect.Value) string {
503 if val.CanInterface() {
504 if timeVal, ok := val.Interface().(time.Time); ok {
505 return formatConfiguredTimeValue(timeVal)
506 }
507 }
508 // For unexported time.Time fields, try to call the String method
509 stringMethod := val.MethodByName("String")
510 if stringMethod.IsValid() {
511 result := stringMethod.Call(nil)
512 if len(result) > 0 {
513 return result[0].String()
514 }
515 }
516 return val.Type().String()
517}
518
519// formatUnexportedValue formats unexported struct fields by kind without using Interface().
520func formatUnexportedValue(val reflect.Value) string {

Callers 1

formatFieldValueFunction · 0.85

Calls 3

IsValidMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected