Using Jscript i want to change 2022-10-20T14:54:29.255+0800 to 13/10/2022 2:54 PM - jscript

i tried using this method :
newDateTime = new Date('2022-10-20T14:54:29.255+0800');
but it return me : "Thu Oct 20 2022 14:54:29 GMT+0800 (Singapore Standard Time)"

Related

SOUP UI Groovy || For loop is looping 50 times where the condition is using this number anywhere

Here I am just taking value(integer) from Properties file and using the same in for loop.
Note : If I use direct number instead of "getTestCasePropertyValue" value it work as expected. Not getting how loop is looping it 50 times.
Groovy script:
def getTestCasePropertyValue = testRunner.testCase.getPropertyValue( "NumOfPayments" )
log.info(getTestCasePropertyValue )
for(i=0; i<=getTestCasePropertyValue; i++)
{
log.info("Test Print"+i)
}
Output:
Fri Mar 06 12:58:47 IST 2020:INFO:2
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print0
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print1
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print2
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print3
...
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print50
Your value from the properties is a String. You will detect problems like this easier, if you use .inspect() to log things.
Also the character '2' is 50 as integer, which then the for loop conditions casts this too.
def getTestCasePropertyValue = "2"
println(getTestCasePropertyValue.inspect())
// → '2'
println(getTestCasePropertyValue as char as int)
// → 50
So best explicitly cast to a number using e.g. .toLong() on the string:
println(getTestCasePropertyValue.toLong().inspect())
// → 2

Read the time frame in the file line by line and assign to a variable in nodejs

I have a file which has values
Start : Wed Dec 18 2019 09:55:15 GMT+0530 (IST)
End : Wed Dec 18 2019 10:11:23 GMT+0530 (IST)
Duration : 00:16:07.278
So I need to get the values coming after
Start :
End :
Duration :
and assign to 3 variables.
Please let me know how we can try that in nodejs
you can parse the date as is with new Date(date string from your file)...
so just split the file into single lines and then remove the starting Start : etc...
as for the Duration, you can split on ":" and then turn the hours and minutes into seconds adding all together in the end...
var st = `Start : Wed Dec 18 2019 09:55:15 GMT+0530 (IST)
End : Wed Dec 18 2019 10:11:23 GMT+0530 (IST)
Duration : 00:16:07.278 `
var lines = st.split("\n")
var start = new Date(lines[0].split("Start :")[1])
var end = new Date(lines[1].split("End :")[1])
var a_dur = lines[2].replace("Duration :", "").split(":")
var dur = Number(a_dur[0]) * 60 * 60 + Number(a_dur[1]) * 60 + Number(a_dur[2])
e_start.innerHTML = start
e_end.innerHTML = end
e_duration.innerHTML = dur
Start:
<div id="e_start"></div><br/> End:
<div id="e_end"></div><br/> Duration:
<div id="e_duration"></div><br/>

rerun a test case in ready api using tear down script

I have a test case "Login" which intermittently fails due to login issues.
I would like to implement a tear down script to get the status of the script and rerun if it failed.
Here is what I implemented and it doesn't work as expected.
testRunner.testCase.setPropertyValue("LoginStatus",
testRunner.getStatus().toString())
def loginStatus = context.expand( '${#TestCase#LoginStatus}' )
int retryAttempts = context.expand( '${#Project#RetryAttempts}' ).toInteger()
def myContext = (com.eviware.soapui.support.types.StringToObjectMap)context
while ( loginStatus == "FAIL" && retryAttempts <= 1) {
retryAttempts = retryAttempts+1
log.info "increment retry attempts-" + retryAttempts
testRunner.testCase.testSuite.project.setPropertyValue( "RetryAttempts",
retryAttempts.toString() )
testCase.run(myContext, false)
log.info "after run statement-"+retryAttempts
}
log.info "before final statement"
testRunner.testCase.testSuite.project.setPropertyValue( "RetryAttempts", "0"
)
The script runs 3 times even though it is configured to rerun once. The logs
Fri May 18 13:55:15 EDT 2018:INFO:increment retry attempts-1
Fri May 18 13:55:16 EDT 2018:INFO:increment retry attempts-2
Fri May 18 13:55:16 EDT 2018:INFO:before final statement
Fri May 18 13:55:16 EDT 2018:INFO:after run statement-2
Fri May 18 13:55:16 EDT 2018:INFO:before final statement
Fri May 18 13:55:16 EDT 2018:INFO:after run statement-1
Fri May 18 13:55:16 EDT 2018:INFO:increment retry attempts-2
Fri May 18 13:55:17 EDT 2018:INFO:before final statement
Fri May 18 13:55:17 EDT 2018:INFO:after run statement-2
Fri May 18 13:55:17 EDT 2018:INFO:before final statement

convert a Date string without timezone in nodejs

I want to convert a string with just the date part, into a Date object in nodejs.
If I do this:
console.log('2010-10-05 ||', new Date('2010-10-05'));
console.log('2010-10-05 00:00:00 ||', new Date('2010-10-05 00:00:00'));
I obtain this in console:
2010-10-05 || Mon Oct 04 2010 19:00:00 GMT-0500 (CDT)
2010-10-05 00:00:00 || Tue Oct 05 2010 00:00:00 GMT-0500 (CDT)
I don't want '2010-10-05' to be converted into '2010-10-04' because of my timezone.
My timezone is -0500 GMT.
How can I create a date by just providing the Date part without the gap ?
Use zeros for hour, minute, second etc.
var date = '2010-10-05',
arr = date.split('-'),
obj = new Date(arr[0], arr[1], arr[2], 0, 0, 0, 0);
Date.UTC uses universal time instead of the local time, if that's what you need
Date.UTC(arr[0], arr[1], arr[2], 0, 0, 0, 0)
console.log('2010-10-05 ||', new Date('2010-10-05' + ' UTC'))
console.log('2010-10-05 00:00:00 ||', new Date('2010-10-05 00:00:00' + ' UTC'))

Slick FAIL TO PARSE TILEMAP

I encountered another problem while learning to work with slick library.
I created a simple little map with 5x5 blocks with size 50x50 pixel.
I tried everything but I still get the same error.
Here my class:
public class PlayState extends BasicGameState{
int stateID = -1;
private TiledMap map;
public PlayState(int stateID){
this.stateID = stateID;
}
#Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
map = new TiledMap("src/resources/map.tmx","src/resources");
}
#Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
map.render(0, 0);
}
#Override
public void update(GameContainer gc, StateBasedGame sbg, int arg2) throws SlickException {
}
#Override
public int getID() {
return stateID;
}
}
and here my error:
Tue Jul 30 13:34:09 CEST 2013 INFO:Slick Build #237
Tue Jul 30 13:34:09 CEST 2013 INFO:LWJGL Version: 2.9.0
Tue Jul 30 13:34:09 CEST 2013 INFO:OriginalDisplayMode: 1600 x 900 x 32 #60Hz
Tue Jul 30 13:34:09 CEST 2013 INFO:TargetDisplayMode: 1280 x 720 x 0 #0Hz
Tue Jul 30 13:34:09 CEST 2013 INFO:Starting display 1280x720
Tue Jul 30 13:34:09 CEST 2013 INFO:Use Java PNG Loader = true
Tue Jul 30 13:34:09 CEST 2013 INFO:Controllers not available
Tue Jul 30 13:34:09 CEST 2013 WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data
java.io.IOException: Transparent color not support in custom PNG Decoder
at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:78)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:62)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:292)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:254)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:187)
at org.newdawn.slick.Image.<init>(Image.java:192)
at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:124)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:661)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at main.states.PlayState.init(PlayState.java:23)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at main.Main.main(Main.java:40)
Tue Jul 30 13:34:09 CEST 2013 ERROR:Unsupport tiled map type: base64,zlib (only gzip base64 supported)
org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)
at org.newdawn.slick.tiled.Layer.<init>(Layer.java:133)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:676)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at main.states.PlayState.init(PlayState.java:23)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at main.Main.main(Main.java:40)
Tue Jul 30 13:34:09 CEST 2013 ERROR:Failed to parse tilemap
org.newdawn.slick.SlickException: Failed to parse tilemap
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:695)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at main.states.PlayState.init(PlayState.java:23)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at main.Main.main(Main.java:40)
Caused by: org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)
at org.newdawn.slick.tiled.Layer.<init>(Layer.java:133)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:676)
... 6 more
I just got this error myself - and solved it. You need to make sure your map properties layer format is set to Base64 (gzip compressed). Looks like that's the format slick expects.
As far as the PNG warnings, apparently slick doesn't like interlaced PNG files, so save as a non-interlaced image

Resources