Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing issue with the custom function #201

Open
Yash1256 opened this issue Jun 10, 2024 · 1 comment
Open

Facing issue with the custom function #201

Yash1256 opened this issue Jun 10, 2024 · 1 comment

Comments

@Yash1256
Copy link

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.

@Yash1256
Copy link
Author

@zhangjianxiongZJX please may you have a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant