Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Facing issue with the custom function  #201

Description

@Yash1256

Hi, I have been using govaluate in my code for a long time.. but I faced this issue very recently.
The issue is described as
I wrote my custom function names as getCustomTimestamp which definition is as below..

"getCustomTimestamp": func(args ...interface{}) (interface{}, error) {
		if len(args) != 1 {
			return nil, ErrInvalidArguments
		}
		fmt.Println("Received args:", args)

		format, ok := args[0].(string)
		if !ok {
			return nil, ErrWrongType
		}

		fmt.Println("Using format:", format)
		if !ok {
			return nil, ErrWrongType
		}
		currentTime := time.Now().In(time.FixedZone("IST", 5*60*60+30*60))
		formattedTime := currentTime.Format(format)
		return formattedTime, nil
	},

And what am I doing is passing string 2024-06-10T09:12:00.084Z to this function and writing an expression which says => getCustomTimestamp("2024-06-10T09:12:00.084Z") or getCustomTimestamp('2024-06-10T09:12:00.084Z')
The logs I received are Received args: [1.71801072e+09] whereas if I pass a normal string like your-name then as the output I receive Received args: [your-name], I am not getting this.. is this automatically parsing the time in some format. Please help me here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions