Documentation
¶
Index ¶
- Variables
- func ExtractTime(s string) (time.Time, error)
- func Format(t time.Time) string
- func FormatNow(fmt TimeFormat) string
- func FormatTo(t time.Time, fmt TimeFormat) string
- func FormatToHumanReadable(t time.Time) string
- func FormatToLegacy(t time.Time) string
- func FormatToTabularDisplay(t time.Time) string
- func Now() string
- func OrNow(t time.Time) time.Time
- func ParseTime(s string) (time.Time, error)
- type TimeFormat
Constants ¶
This section is empty.
Variables ¶
var ( SafeForTestingRE = regexp.MustCompile(`.*(\d{2}-[a-zA-Z]{3}-\d{4}_\d{2}-\d{2}-\d{2}.\d{6}).*`) HumanReadableRE = regexp.MustCompile(`.*(\d{2}-[a-zA-Z]{3}-\d{4}_\d{2}:\d{2}:\d{2}).*`) HumanReadableOneDriveRE = regexp.MustCompile(`.*(\d{2}-[a-zA-Z]{3}-\d{4}_\d{2}-\d{2}-\d{2}).*`) )
these regexes are used to extract time formats from strings. Their primary purpose is to identify the folders produced in external data during automated testing. For safety, each time format described above should have a matching regexp.
var (
ErrNoTimeString = clues.New("no substring contains a known time format")
)
Functions ¶
func ExtractTime ¶
ExtractTime greedily retrieves a timestamp substring from the provided string. returns ErrNoTimeString if no match is found.
func Format ¶
Format produces the standard format for corso time values. Always formats into the UTC timezone.
func FormatNow ¶
func FormatNow(fmt TimeFormat) string
FormatNow produces the current time in UTC using the provided time format.
func FormatTo ¶
func FormatTo(t time.Time, fmt TimeFormat) string
FormatTo produces the a datetime with the given format.
func FormatToHumanReadable ¶
FormatToHumanReadable produces a simple datetime of the format "02-Jan-2006_15:04:05"
func FormatToLegacy ¶
FormatToLegacy produces standard format for string values that are placed in SingleValueExtendedProperty tags
func FormatToTabularDisplay ¶
FormatToTabularDisplay produces the standard format for displaying a timestamp as part of user-readable cli output. "2016-01-02T15:04:05Z"
Types ¶
type TimeFormat ¶
type TimeFormat string
const ( // Standard is the canonical format used for all data storage in corso Standard TimeFormat = time.RFC3339Nano // DateOnly is accepted by the CLI as a valid input for timestamp-based // filters. Time and timezone are assumed to be 00:00:00 and UTC. DateOnly TimeFormat = "2006-01-02" // TabularOutput is used when displaying time values to the user in // non-json cli outputs. TabularOutput TimeFormat = "2006-01-02T15:04:05Z" // Legacy is used in /exchange/service_restore to comply with certain // graphAPI time format requirements. Legacy TimeFormat = time.RFC3339 // HumanReadable is the default value appended to the root restoration folder name. HumanReadable TimeFormat = "02-Jan-2006_15:04:05" // HumanReadableDriveItem modifies SimpleDateTimeFormat to comply with onedrive folder // restrictions: primarily swapping `-` instead of `:` which is a reserved character. HumanReadableDriveItem TimeFormat = "02-Jan-2006_15-04-05" // m365 will remove the :00 second suffix on folder names, resulting in the following formats. ClippedHuman TimeFormat = "02-Jan-2006_15:04" ClippedHumanDriveItem TimeFormat = "02-Jan-2006_15-04" // SafeForTesting is used for testing restore destination folders. // Microsecond granularity prevents collisions in parallel package or workflow runs. SafeForTesting TimeFormat = HumanReadableDriveItem + ".000000" // M365dateTimeTimeZoneTimeFormat is the format used by M365 for datetimetimezone resource // https://learn.microsoft.com/en-us/graph/api/resources/datetimetimezone?view=graph-rest-1.0 M365DateTimeTimeZone TimeFormat = "2006-01-02T15:04:05.0000000" )