Add support for weeks

Created on 21 August 2019, almost 5 years ago
Updated 26 May 2024, about 1 month ago

\DateInterval does allow for weeks in the interval string, however it cannot be used in conjunction with days.

In my situation I need weeks support to allow for building setting some durations.

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia gordon Melbourne

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.0 & MySQL 5.7
    last update 5 months ago
    Composer require failure
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 5 months ago
    8 fail
  • Status changed to Needs review 5 months ago
  • πŸ‡ΊπŸ‡¦Ukraine sickness29

    Hi @dww
    I have another approach to this since PHP DateInterval does not natively support weeks I do not change any DataTypes to make them represent true php iso standards and not be some mess with ifs.
    Instead I have added another column for weeks to store alondside and added getValue() method to field so duration and seconds are adjusted to have those weeks included.
    I have also reviewed test since they are running badly on D10, fixed field creation and removed deprecated code.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 5 months ago
    47 pass
  • Merge request !14Weeks support and test for it β†’ (Merged) created by sickness29
  • Pipeline finished with Skipped
    about 1 month ago
    #178133
  • Status changed to Fixed about 1 month ago
  • Status changed to Needs work about 1 month ago
  • πŸ‡©πŸ‡ͺGermany diqidoq Berlin | Hamburg | New York | London | Paris

    - Upgrading drupal/duration_field (dev-2.x cdf331a => dev-2.x 20674f7): Checking out 20674f7714 from cache

    This commit causes:

    [error] Cannot add field 'node__field_duration_hms.field_duration_hms_weeks': field already exists.

    ... when updating 2.0 dev from previous 2.0 dev and this breaks the site if it is part of a project update process since non of the required db updates can run being interrupted by this error.

Production build 0.69.0 2024