timedurationtype

package
Version: v0.0.0-...-44d8e33 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeCheckerTimeDuration = &loader.Checker{
	Type: TypeTimeDuration,
	Checker: func(a *loader.Assembler, rv reflect.Value) (bool, error) {
		return rv.Type() == rtypeTimeDuration, nil
	},
}

TypeCheckerTimeDuration type checker for int64

View Source
var TypeTimeDuration = loader.Type("loader.types.timeduration")
View Source
var UnifierTimeDuration = loader.UnifierFunc(func(a *loader.Assembler, rv reflect.Value) (bool, error) {
	var d time.Duration
	str := ""
	strptr := &str
	ok, err := loader.UnifierString.Unify(a, reflect.ValueOf(strptr).Elem())
	if err != nil {
		return false, nil

	}
	if ok {
		if *strptr == "" {
			return true, nil
		}
		d, err = time.ParseDuration(*strptr)
		if err != nil {
			return false, nil
		}
	} else {
		var i64 int64
		intptr := &i64
		ok, err = loader.UnifierNumber.Unify(a, reflect.ValueOf(intptr).Elem())
		if ok == false || err != nil {
			return false, nil
		}
		d = time.Duration(*intptr * int64(time.Second))
	}
	err = loader.SetValue(rv, reflect.ValueOf(d))
	if err != nil {
		return false, err
	}
	return true, nil
})

UnifierTimeDuration unifier for time field

Functions

func RegisterType

func RegisterType()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL