Skip to content

Make FormatTimeString and ParseTimeString methods #12658

@ValarDragon

Description

@ValarDragon

Summary

We should make string counterparts to FormatTimeBytes and ParseTimeBytes

// Formats a time.Time into a []byte that can be sorted
func FormatTimeBytes(t time.Time) []byte {
return []byte(t.UTC().Round(0).Format(SortableTimeFormat))
}
// Parses a []byte encoded using FormatTimeKey back into a time.Time
func ParseTimeBytes(bz []byte) (time.Time, error) {
str := string(bz)
t, err := time.Parse(SortableTimeFormat, str)
if err != nil {
return t, err
}
return t.UTC().Round(0), nil
}
, and then make the bytes method call into those


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions