Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #269 from pontusmelke/4.1-duration-format
Browse files Browse the repository at this point in the history
Nicer formatting for Duration
  • Loading branch information
pontusmelke authored Oct 23, 2020
2 parents 93d2e07 + d8eca2b commit 3a77249
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ public void tearDown() throws Exception
shell.execute( "MATCH (n) DETACH DELETE (n)" );
}

@Test
public void parseDuration() throws CommandException
{
//when
shell.execute( "RETURN duration({months:0.75})" );

//then
assertThat( linePrinter.output(), containsString( "P22DT19H51M49.5S" ) );
}

@Test
public void cypherWithNoReturnStatements() throws CommandException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.neo4j.driver.types.Point;
import org.neo4j.driver.types.Relationship;
import org.neo4j.shell.state.BoltResult;
import org.neo4j.values.storable.DurationValue;

import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
Expand Down Expand Up @@ -210,6 +211,8 @@ default String formatValue( final Value value )
return pathAsString( value.asPath() );
case POINT:
return pointAsString( value.asPoint() );
case DURATION:
return DurationValue.parse( value.toString() ).prettyPrint();
case ANY:
case BOOLEAN:
case BYTES:
Expand All @@ -222,7 +225,6 @@ default String formatValue( final Value value )
case DATE_TIME:
case LOCAL_TIME:
case LOCAL_DATE_TIME:
case DURATION:
case NULL:
default:
return value.toString();
Expand Down

0 comments on commit 3a77249

Please sign in to comment.