From 024b3f2ec685c76da78c328d7de44ab3f49c31ff Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Mon, 28 Apr 2025 10:04:27 +0200 Subject: [PATCH 1/3] Add timezone to date format Signed-off-by: Paolo Di Tommaso --- modules/nf-commons/src/main/nextflow/util/SysHelper.groovy | 2 +- .../nf-commons/src/test/nextflow/util/SysHelperTest.groovy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy b/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy index 084d4ea6f1..a8bf39aa61 100644 --- a/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy +++ b/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy @@ -37,7 +37,7 @@ class SysHelper { public static final String DEFAULT_DOCKER_PLATFORM = 'linux/amd64' - private static String DATE_FORMAT = 'dd-MMM-yyyy HH:mm' + private static String DATE_FORMAT = 'dd-MMM-yyyy HH:mm Z' /** * Given a timestamp as epoch time convert to a string representation diff --git a/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy b/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy index c59b936d39..6b2338e634 100644 --- a/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy +++ b/modules/nf-commons/src/test/nextflow/util/SysHelperTest.groovy @@ -88,8 +88,8 @@ class SysHelperTest extends Specification { where: dateInMilis | locale | expected - 1470901220000 | 'en' | '11-Aug-2016 09:40' - 1470901220000 | 'es' | '11-Aug-2016 09:40' + 1470901220000 | 'en' | '11-Aug-2016 09:40 +0200' + 1470901220000 | 'es' | '11-Aug-2016 09:40 +0200' } } From cebad3688e949a337773d0ec224dc1661992e484 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 14 May 2025 16:29:19 -0400 Subject: [PATCH 2/3] Make datetime format configurable [ci fast] Signed-off-by: Paolo Di Tommaso --- .../groovy/nextflow/trace/ReportSummary.groovy | 2 -- .../src/main/nextflow/util/SysHelper.groovy | 10 +++++++++- .../src/test/nextflow/util/SysHelperTest.groovy | 17 ++++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) 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 a8bf39aa61..a026f7ea59 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 @@ -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 6b2338e634..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 +0200' - 1470901220000 | 'es' | '11-Aug-2016 09:40 +0200' + 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' } } From e483aafc326057350e1dcc28140f37748e53e388 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 14 May 2025 16:43:31 -0400 Subject: [PATCH 3/3] Fix failing tests [ci fast] Signed-off-by: Paolo Di Tommaso --- modules/nf-commons/src/main/nextflow/util/SysHelper.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy b/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy index a026f7ea59..660c45a904 100644 --- a/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy +++ b/modules/nf-commons/src/main/nextflow/util/SysHelper.groovy @@ -38,7 +38,7 @@ class SysHelper { public static final String DEFAULT_DOCKER_PLATFORM = 'linux/amd64' - private static String DATE_FORMAT = 'dd-MMM-yyyy HH:mm Z' + private static final String DATE_FORMAT = 'dd-MMM-yyyy HH:mm' /** * Given a timestamp as epoch time convert to a string representation