I'm delving into the travis-ci.org logs of a very simple app that was built to demonstrate testing and continuous integration.
I see timestamps given in each raw log file, but I don't know a simple way to convert them to readable dates?
There seem to be two different formats.
I'm on a mac, so bash or python or an online calculator answer would be terrific.
thank you!
Here are the 4 sub-builds, each for a different jvm:
4.1 https://travis-ci.org/ihassin/cucumber-jvm/jobs/40111229
travis_time:end:121a64f6:start=1415224070390184790,finish=1415224071568557470,duration=1178372680
4.2 https://travis-ci.org/ihassin/cucumber-jvm/jobs/40111230
0Ktravis_time:start:094d841c
4.3 https://travis-ci.org/ihassin/cucumber-jvm/jobs/40111231
travis_time:start:00067b60
4.4
https://travis-ci.org/ihassin/cucumber-jvm/jobs/40111232
travis_time:start:0011ba85
The timestamps are in nanoseconds. To get a normal Unix timestamp, you need to divide them by 10^6. For the value finish=1415224071568557470, for example, in JavaScript you could do:
new Date(1415224071568557470 / 1e6).toUTCString() // 'Wed, 05 Nov 2014 21:47:51 GMT'
Related
How would I convert a human readable time (in any format, such as Tue, 1 Jul 2003 10:52:37 +0200) into a SystemTime, in a cross-platform way? I know about chrono::DateTime::from_rfc2822(), but I've been searching for quite a while and I can't find a way to convert a DateTime into a SystemTime. This conversion also needs to be cross-platform, so I can't use the platform-specific epochs (such as UNIX_EPOCH).
Does anyone have any advice or ideas on how to do this?
There is a conversion available for DateTime<Tz> to SystemTime, so you just need to call .into():
let system_time: SystemTime = DateTime::parse_from_rfc2822("Tue, 1 Jul 2003 10:52:37 +0200").unwrap().into();
Playground
I have a script that needs two timestamps, one for 'today' at 02:30 and one for 'tomorrow' at 02:30. To generate the dates was fairly easy, using;
date1=${__time("yyyy.MM.dd 02:30:00")}
date2=${__timeShift("yy.MM.dd 02:30:00",,P1D,,)}
But the POST request needs the dates in Epoch format. How can I convert the output of the above into Epochs?
An option that I found was to use;
date1a=date1.getTime().toString()
But that didn't work (no signature of method). Related to that I did find a jmeter 5.3 bug where the dateutil.jar is missing, but adding it made no difference.
There are lots of options for converting Epoch to human readable, but they aren't reversible processes.
Alternatively, is there a way of calculating the Epoch directly, again for 'today' at 2:30 and 'tomorrow' at 2:30?
Don't inline JMeter Functions or Variables into scripts, as per JSR223 Sampler documentation
The JSR223 test elements have a feature (compilation) that can significantly increase performance.
When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters
I believe you can achieve your goal using good old SimpleDateFormat, example code to parse your string and add 24 hours to it:
def today = new java.text.SimpleDateFormat('yyyy.MM.dd hh:mm:ss').parse('2020.11.06 02:30:00')
log.info('Today: ' + today)
def tomorrow = new Date(today.getTime() + 86400000L)
log.info('Tomorrow: ' + tomorrow)
log.info('Today epoch : ' + today.getTime())
log.info('Tomorrow epoch: ' + tomorrow.getTime())
Demo:
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
Like in a similar query on this forum I need, but I need it to work in Impala:
In a workaround my colleague and myself attempted the following:
-- combine start date and time into a datetime
-- impala can't handle am/pm so need to look for pm indicator and add 12 hours
-- and then subtract 12 hours if it's 12:xx am or pm
================
t1.appt_time,
hours_add(
to_timestamp(concat(to_date(t1.appt_date),' ',t1.appt_time),'yyyy-MM-dd H:mm'),
12*decode(lower(strright(t1.appt_time,2)),"pm",1,0) -
12*decode(strleft(t1.appt_time,2),'12',1,0)
) as appt_datetime,
t1. ...
=========
Has anybody an easier and more elegant approach ?
Your workaround is valid, Impala does currently support AM/PM formatting for dates. There are a few open issues related
https://issues.apache.org/jira/browse/IMPALA-3381
https://issues.apache.org/jira/browse/IMPALA-5237
https://issues.apache.org/jira/browse/IMPALA-2262
I am debugging a program in MacOSX,
and I need that this program thinks we are one year later than the one given by the operating system.
I cannot change the time of the operation system, because I need to run a second program concurrently with the correct time.
I could modify the code of the first program to add one year each time it gets the time from the operation system, but the code is too big to do that; I prefer not to use this solution.
I heard once that there is a command in Unix to run a program with a fake/mocked time.
Do you know about it?
I haven't tried it, but libfaketime claims to do what you need.
Quoted from the website:
As an example, we want the "date" command to report our faked time. To do so, we could use the following command line:
user#host> date
Tue Nov 23 12:01:05 CEST 2007
user#host> LD_PRELOAD=/usr/local/lib/libfaketime.so.1 FAKETIME="-15d" date
Mon Nov 8 12:01:12 CEST 2007
Assuming the lib works as advertised, you can trick your program into thinking it was running a year ahead using:
LD_PRELOAD=/usr/local/lib/libfaketime.so.1 FAKETIME="+1y" ./your_program
What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command?
For all Unix-ish operating systems, when using the GNU date command:
date +%z
Example, for Eastern European Time (my timezone):
[moocha#helium ~]$ date +%z
+0200
If what you want is the non-summer/daylight-savings offset, you'd have to do something like:
date -d 'Jan 1' +%z
(or Jul in the southern hemisphere). This works with date from GNU coreutils, anyway.
Shockingly enough, I don't see any way to get the tm_isdst flag from date.
I figure that if worse comes to worse I can just send a request to an NTP server and take the difference of it and the current local time, but that seems kind of wasteful if the system knows its offset.