diff --git a/modules/nextflow/src/main/groovy/nextflow/trace/ReportSummary.groovy b/modules/nextflow/src/main/groovy/nextflow/trace/ReportSummary.groovy index f11c23a8f3..0399624046 100644 --- a/modules/nextflow/src/main/groovy/nextflow/trace/ReportSummary.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/trace/ReportSummary.groovy @@ -64,8 +64,6 @@ class ReportSummary { } } - - /** * Hold the summary for each series ie. cpu, memory, time, disk reads, disk writes */ diff --git a/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy b/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy index 084d4ea6f1..660c45a904 100644 --- a/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy +++ b/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy @@ -25,6 +25,7 @@ import groovy.transform.CompileStatic import groovy.transform.Memoized import groovy.transform.PackageScope import groovy.util.logging.Slf4j +import nextflow.SysEnv import nextflow.file.FileHelper /** * System helper methods @@ -37,7 +38,7 @@ class SysHelper { public static final String DEFAULT_DOCKER_PLATFORM = 'linux/amd64' - private static String DATE_FORMAT = 'dd-MMM-yyyy HH:mm' + private static final String DATE_FORMAT = 'dd-MMM-yyyy HH:mm' /** * Given a timestamp as epoch time convert to a string representation @@ -66,11 +67,18 @@ class SysHelper { * The formatted date string */ static String fmtDate(Date date, TimeZone tz=null) { - def formatter=new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH) + final formatter=new SimpleDateFormat(fmtEnv(), Locale.ENGLISH) if(tz) formatter.setTimeZone(tz) formatter.format(date) } + static private String fmtEnv() { + final result = SysEnv.get('NXF_DATE_FORMAT', DATE_FORMAT) + return result.toLowerCase() == 'iso' + ? "yyyy-MM-dd'T'HH:mm:ssXXX" + : result + } + /** * Read the system uptime as returned by the {@code uptime} Linux tool * diff --git a/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy b/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy index c59b936d39..911e1c5143 100644 --- a/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy +++ b/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy @@ -19,6 +19,7 @@ package nextflow.util import java.lang.management.ManagementFactory import com.sun.management.OperatingSystemMXBean +import nextflow.SysEnv import nextflow.file.FileHelper import spock.lang.Specification /** @@ -74,6 +75,9 @@ class SysHelperTest extends Specification { def 'should format date string' () { given: + def env = dateFormat ? [NXF_DATE_FORMAT:dateFormat] : [:] + SysEnv.push(env) + and: def defLocale = Locale.getDefault(Locale.Category.FORMAT) def useLocale = new Locale.Builder().setLanguage(locale).build() Locale.setDefault(Locale.Category.FORMAT, useLocale) @@ -85,11 +89,18 @@ class SysHelperTest extends Specification { cleanup: Locale.setDefault(Locale.Category.FORMAT, defLocale) + SysEnv.pop() where: - dateInMilis | locale | expected - 1470901220000 | 'en' | '11-Aug-2016 09:40' - 1470901220000 | 'es' | '11-Aug-2016 09:40' + dateInMilis | locale | dateFormat | expected + 1470901220000 | 'en' | null | '11-Aug-2016 09:40' + 1470901220000 | 'es' | null | '11-Aug-2016 09:40' + and: + 1470901220000 | 'en' | 'iso' | '2016-08-11T09:40:20+02:00' + 1470901220000 | 'es' | 'iso' | '2016-08-11T09:40:20+02:00' + and: + 1470901220000 | 'en' | "yyyy-MM-dd'T'HH:mm:ss.SSS" | '2016-08-11T09:40:20.000' + 1470901220000 | 'es' | "yyyy-MM-dd'T'HH:mm:ss.SSS" | '2016-08-11T09:40:20.000' } }