Skip to content

Implement configurable date time format with timezone support#6013

Merged
pditommaso merged 12 commits intomasterfrom
add-tz-to-datefmt
Aug 14, 2025
Merged

Implement configurable date time format with timezone support#6013
pditommaso merged 12 commits intomasterfrom
add-tz-to-datefmt

Conversation

@pditommaso
Copy link
Member

@pditommaso pditommaso commented Apr 28, 2025

Summary

This PR implements configurable date and time formatting support in Nextflow to make timestamps consistent and ISO-compliant across all outputs.

Features Added

  • Configurable Date Format: New NXF_DATE_FORMAT environment variable allows users to customize date formatting
  • ISO Format Support: Set NXF_DATE_FORMAT=iso for ISO 8601 format with timezone information (2016-08-11T09:40:20+02:00)
  • Default Format Updated: Changed to dd-MMM-yyyy HH:mm:ss (includes seconds for better precision)
  • Universal Template Support: All notification templates now use the configurable format:
    • Email notifications (HTML and text)
    • HTML execution reports
    • ANSI console output

Technical Implementation

  • Enhanced SysHelper: Added support for OffsetDateTime objects commonly used in workflow metadata
  • Template Binding: Fixed template engines to properly access SysHelper formatting methods
  • Backward Compatibility: Existing behavior preserved - only adds new functionality

Usage Examples

# Default format (dd-MMM-yyyy HH:mm:ss)
nextflow run workflow.nf
# Output: "11-Aug-2016 09:40:20"

# ISO format with timezone
export NXF_DATE_FORMAT=iso
nextflow run workflow.nf  
# Output: "2016-08-11T09:40:20+02:00"

# Custom format
export NXF_DATE_FORMAT="yyyy-MM-dd HH:mm"
nextflow run workflow.nf
# Output: "2016-08-11 09:40"

Documentation Added

  • Environment Variables Reference: Added NXF_DATE_FORMAT documentation with version 25.07.0-edge
  • Migration Guide: Added feature description to 25.10 migration guide with usage examples
  • Version Information: Properly documented as available since version 25.07.0-edge

Files Modified

  • SysHelper.groovy - Core formatting logic with environment variable support
  • notification.html & notification.txt - Email template updates
  • ReportTemplate.html - HTML report template updates
  • AnsiLogObserver.groovy - Console output formatting
  • WorkflowNotifier.groovy & ReportObserver.groovy - Template binding fixes
  • docs/reference/env-vars.md - Environment variable documentation
  • docs/migrations/25-10.md - Feature documentation and examples
  • Comprehensive test coverage added and updated

Testing

  • ✅ All existing tests pass
  • ✅ New test coverage for OffsetDateTime support
  • ✅ Template rendering tests for all notification types
  • ✅ Environment variable configuration tests
  • ✅ ISO format and timezone handling tests

This addresses the inconsistency issues mentioned in #4754 by providing a centralized, configurable date formatting system.

🤖 Generated with Claude Code

Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@pditommaso pditommaso marked this pull request as draft April 28, 2025 08:11
@netlify
Copy link

netlify bot commented Apr 28, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 6f7c13c
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/689e59095250fd0008d01a78

@pditommaso pditommaso changed the title Add timezone to date format Make timestamps ISO compliant May 14, 2025
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@pditommaso

This comment was marked as outdated.

Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@pditommaso pditommaso force-pushed the master branch 3 times, most recently from b4b321e to 069653d Compare June 4, 2025 18:54
pditommaso and others added 4 commits June 9, 2025 14:48
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
…FORMAT

- Add configurable date formatting via NXF_DATE_FORMAT environment variable
- Support ISO format with timezone (NXF_DATE_FORMAT=iso)
- Default format changed to 'dd-MMM-yyyy HH:mm:ss'
- Add OffsetDateTime support to SysHelper.fmtDate()
- Update all notification templates to use configurable formatting:
  * Email notifications (HTML and text)
  * HTML execution reports
  * ANSI console output
- Add comprehensive test coverage for all date format variations
- Fix template binding to support SysHelper in notification templates

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pditommaso pditommaso changed the title Make timestamps ISO compliant Implement configurable date time format with timezone support Aug 14, 2025
@pditommaso pditommaso marked this pull request as ready for review August 14, 2025 20:35
- Add NXF_DATE_FORMAT to environment variables reference
- Document version 25.07.0-edge availability
- Add feature description to 25.10 migration guide with examples
- Restore OffsetDateTime test that was accidentally removed
- Document ISO format support and default format change

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pditommaso pditommaso requested a review from a team as a code owner August 14, 2025 20:44
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@pditommaso pditommaso merged commit 163cd37 into master Aug 14, 2025
10 checks passed
@pditommaso pditommaso deleted the add-tz-to-datefmt branch August 14, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant