Movatterモバイル変換


[0]ホーム

URL:


customfuncs

package
v1.0.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2024 License:MITImports:8Imported by:4

Details

Repository

github.com/jf-tech/omniparser

Links

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonCustomFuncs = map[string]CustomFuncType{"coalesce":Coalesce,"concat":Concat,"dateTimeLayoutToRFC3339":DateTimeLayoutToRFC3339,"dateTimeToEpoch":DateTimeToEpoch,"dateTimeToRFC3339":DateTimeToRFC3339,"epochToDateTimeRFC3339":EpochToDateTimeRFC3339,"lower":Lower,"now":Now,"upper":Upper,"uuidv3":UUIDv3,}

CommonCustomFuncs contains the most basic and frequently-used custom functions that are suitablefor all versions of schemas.

Functions

funcCoalesce

func Coalesce(_ *transformctx.Ctx, strs ...string) (string,error)

Coalesce returns the first non-empty string of the input strings. If no input strings are given orall of them are empty, then an empty string is returned. Note: a blank string (with only whitespaces)is not considered as empty.

funcConcat

func Concat(_ *transformctx.Ctx, strs ...string) (string,error)

Concat concatenates a number of strings together. If no strings specified, "" is returned.

funcDateTimeLayoutToRFC3339

func DateTimeLayoutToRFC3339(_ *transformctx.Ctx, datetime, layout, layoutTZ, fromTZ, toTZstring) (string,error)

DateTimeLayoutToRFC3339 parses a 'datetime' string according a given 'layout' and normalizes and returns itin RFC3339 format. 'layoutTZ' specifies whether the 'layout' contains timezone info (such as tz offset, tzshort names lik 'PST', or standard IANA tz long name, such as 'America/Los_Angeles'); note 'layoutTZ' is astring with two possible values "true" or "false". 'fromTZ' is only used if 'datetime'/'layout' don't containTZ info; if not specified, the parser will keep the original TZ (or lack of it) of 'datetime'. 'toTZ' decideswhat TZ the output RFC3339 date time will be in.

funcDateTimeToEpoch

func DateTimeToEpoch(_ *transformctx.Ctx, datetime, fromTZ, unitstring) (string,error)

DateTimeToEpoch parses a 'datetime' string intelligently, and returns its epoch number. 'fromTZ'is only used if 'datetime' doesn't contain TZ info; if not specified, the parser will keep theoriginal TZ (or lack of it) of 'datetime'. 'unit' determines the time unit resolution of theoutput epoch number.

funcDateTimeToRFC3339

func DateTimeToRFC3339(_ *transformctx.Ctx, datetime, fromTZ, toTZstring) (string,error)

DateTimeToRFC3339 parses a 'datetime' string intelligently, normalizes and returns it in RFC3339 format.'fromTZ' is only used if 'datetime' doesn't contain TZ info; if not specified, the parser will keep theoriginal TZ (or lack of it) of 'datetime'. 'toTZ' decides what TZ the output RFC3339 date time will be in.

funcEpochToDateTimeRFC3339

func EpochToDateTimeRFC3339(_ *transformctx.Ctx, epoch, unitstring, tz ...string) (string,error)

EpochToDateTimeRFC3339 translates the 'epoch' timestamp under the given 'unit' into an RFC3339 formatteddatetime string in the given timezone 'tz', if specified.

funcLower

func Lower(_ *transformctx.Ctx, sstring) (string,error)

Lower lowers the case of an input string.

funcNow

func Now(_ *transformctx.Ctx) (string,error)

Now returns the current time in UTC in RFC3339 format.

funcUUIDv3

func UUIDv3(_ *transformctx.Ctx, sstring) (string,error)

UUIDv3 uses MD5 to produce a consistent/stable UUID for an input string.

funcUpper

func Upper(_ *transformctx.Ctx, sstring) (string,error)

Upper uppers the case of an input string.

Types

typeCustomFuncType

type CustomFuncType = interface{}

CustomFuncType is the type of custom function. Has to use interface{} given we supportnon-variadic and variadic functions.

typeCustomFuncs

type CustomFuncs = map[string]CustomFuncType

CustomFuncs is a map from custom func names to an actual custom func.

funcMerge

func Merge(funcs ...CustomFuncs)CustomFuncs

Merge merges multiple custom func maps into one.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp