Skip to content

Commit

Permalink
Remove milliseconds for data set dates #823
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Sep 12, 2023
1 parent 4f30c1b commit a82c2ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package au.org.ala.ecodata.paratoo

import au.org.ala.ecodata.DateUtil
import au.org.ala.ecodata.metadata.PropertyAccessor
import groovy.util.logging.Slf4j

Expand All @@ -22,12 +23,19 @@ class ParatooProtocolConfig {
apiEndpoint ?: defaultEndpoint(surveyId)
}

private static String removeMilliseconds(String isoDateWithMillis) {
if (!isoDateWithMillis) {
return isoDateWithMillis
}
DateUtil.format(DateUtil.parseWithMilliseconds(isoDateWithMillis))
}

String getStartDate(Map surveyData) {
getProperty(surveyData, startDatePath)
removeMilliseconds(getProperty(surveyData, startDatePath))
}

String getEndDate(Map surveyData) {
getProperty(surveyData, endDatePath)
removeMilliseconds(getProperty(surveyData, endDatePath))
}

Map getSurveyId(Map surveyData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ParatooProtocolConfigSpec extends Specification {
ParatooProtocolConfig config = new ParatooProtocolConfig(vegetationMappingConfig)

expect:
config.getStartDate(surveyData) == '2023-09-08T23:39:00.520Z'
config.getStartDate(surveyData) == '2023-09-08T23:39:00Z'
config.getEndDate(surveyData) == null
config.getGeoJson(surveyData) == [type:'Point', coordinates:[149.0651536, -35.2592398]]
}
Expand Down

0 comments on commit a82c2ac

Please sign in to comment.