-
Notifications
You must be signed in to change notification settings - Fork 493
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
Added apoc.date.convert() and apoc.date.add() #291
Conversation
src/main/java/apoc/date/Date.java
Outdated
@@ -136,6 +136,19 @@ public String systemTimezone() { | |||
return TimeZone.getDefault().getID(); | |||
} | |||
|
|||
@UserFunction | |||
@Description("apoc.date.convert(12345,'ms|s|m|h|d','ms|s|m|h|d') convert a time unit into a different time unit") | |||
public Long convert(@Name("time") long time, @Name(value = "unit") String unit, @Name(value = "toUnit") String toUnit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any sensible default values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 'ms' for the unit
value, but I'm wondering if in this case a default value would be easier to work with or make usage more error-prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not worth it then.
looks good to me, can you add them to docs/overview.adoc too? |
src/main/java/apoc/date/Date.java
Outdated
@@ -136,6 +136,19 @@ public String systemTimezone() { | |||
return TimeZone.getDefault().getID(); | |||
} | |||
|
|||
@UserFunction | |||
@Description("apoc.date.convert(12345,'ms|s|m|h|d','ms|s|m|h|d') convert a time unit into a different time unit") | |||
public Long convert(@Name("time") long time, @Name(value = "unit") String unit, @Name(value = "toUnit") String toUnit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not worth it then.
c3f6b59
to
a7385ea
Compare
* Added apoc.date.convert() and apoc.date.add() and unit tests * Added documentation.
This fulfills the feature request in #289.