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

Provide "time" as timestamp (milli seconds since epoch) #60

Open
rmannibucau opened this issue Oct 20, 2023 · 3 comments
Open

Provide "time" as timestamp (milli seconds since epoch) #60

rmannibucau opened this issue Oct 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@rmannibucau
Copy link

rmannibucau commented Oct 20, 2023

Describe the idea (required)

Some plugins need a long to represent a timestamp, with the time format it needs some custom conversion, since time values come from long it should be possible to just propagate them.

Tell us about the expected behaviour (required)

Could be using timeLong or alike as suffix.

Context (optional)

No response

PS: it looks quite straight forward but if it helps I'm happy to start to do some PR but was not sure of the solution so didn't start any yet

@rmannibucau rmannibucau added enhancement New feature or request to-triage labels Oct 20, 2023
@TheSnoozer
Copy link
Contributor

TheSnoozer commented Oct 20, 2023

Just to clarify: Would the Unix epoch time like a 1697817375 be essentially what you are asking?

Per https://en.wikipedia.org/wiki/Unix_time

Unix time[a] is a date and time representation widely used in computing. It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds. In modern computing, values are sometimes stored with higher granularity, such as microseconds or nanoseconds.

Do we need to be more precise than seconds? What about Timezones? I guess since epoch is counting from 00:00:00 UTC on 1 January 1970 we would then assume that number of seconds represents the difference to the local UTC time.

@rmannibucau
Copy link
Author

@TheSnoozer I need milliseconds precision but I guess ${git.xxxx.time.ms}000 can do the trick so it would work. Value must be compatible with Instant;ofEpoch but the second version is sufficient if simpler for you (and maybe more generic).

@TheSnoozer
Copy link
Contributor

Hello,
thanks for the quick feedback! Ok, should make little difference to report the number of milli seconds since epoch (https://currentmillis.com) which would be something like 1697817924644.

A

import java.time.Instant;

class HelloWorld {
    public static void main(String[] args) {
        System.out.println(Instant.ofEpochMilli(1697817924644L));
    }
}

would print

2023-10-20T16:05:24.644Z

@TheSnoozer TheSnoozer changed the title Provide "time" as timestamp Provide "time" as timestamp (milli seconds since epoch) Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants