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

Add the unix time expression #753

Closed
TrademarkTM opened this issue Jul 28, 2017 · 5 comments
Closed

Add the unix time expression #753

TrademarkTM opened this issue Jul 28, 2017 · 5 comments
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.

Comments

@TrademarkTM
Copy link

TrademarkTM commented Jul 28, 2017

Hello people.
I'm suggesting this because it'd be way easier to use, and even easier to implement.

Why?

  • It's a number, so you can do whatever you can do any sort of math with it.
  • You wouldn't need to parse as date or anything like that.
  • For cooldowns it would work a lot better, just a simple subtraction and it is done.
  • If you want only minutes for example all you gotta do is divide by 60, without all the 1 hour, 3 minutes and 5 seconds.
  • Easier to store and manage.

It'd take a couple lines long unix = Instant.now().getEpochSecond(); and will make date more versatile.
Made this but it's not worth the 1 ms.

Hope you implement this!
Thanks!

@Snow-Pyon
Copy link

Please look at the docs before asking something like this, he already added it a while ago:
http://bensku.github.io/Skript/expressions.html#ExprUnixTime

@TrademarkTM
Copy link
Author

TrademarkTM commented Jul 28, 2017

Alright, sorry, I searched only in skUnity. But it seems not to work:

command /something:
	trigger:
		broadcast "%unix time of now%"

[08:19:57 INFO]: [Skript] # /something
[08:19:57 INFO]: 2017-07-28 08:19:57 BRT
[08:19:57 INFO]: [Skript] # something took 0.363203 milliseconds

Parsing as number:

[08:24:23 INFO]: [Skript] # /something
[08:24:23 INFO]: <none>
[08:24:23 INFO]: [Skript] # something took 0.519808 milliseconds

Also, it does not work in math correctly (I could use my unix function normally):

unix time of now - {cooldown} < 300

[08:21:35 ERROR]: Can't compare 'unix time of now - {cooldown}' with an integer (RuneEssentials.sk, line 31: unix time of now - {cooldown} < 300')

I know I can parse it, but as it's seconds since 1970, shouldn't it be a number?

My server / Skript info
Skript dev29
Date format is default (that may be the cause, because I live in Brazil and the dates may differ)
Version 1.12
Addons only skQuery

Hope it can be fixed soon.
Thanks once again and sorry for the thread.

@bensku
Copy link
Member

bensku commented Jul 28, 2017

The existing expression is not seconds since epoch. Actually I don't recall why I named it so...

@bensku bensku added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Jul 28, 2017
@TrademarkTM
Copy link
Author

So.. could you add it in the next update?
Don't think it'll take more than 30 seconds to create this expression.

Thanks.

@bensku
Copy link
Member

bensku commented Aug 8, 2017

Next feature release, probably. But I try to avoid adding anything new to hotfixes to not introduce new bugs.

bensku added a commit that referenced this issue Sep 3, 2017
@bensku bensku closed this as completed Sep 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

No branches or pull requests

3 participants