Commit ead89b7a authored by Brian Suttis's avatar Brian Suttis Committed by Jonathan Sacksick
Browse files

Issue #3209414 by bsuttis, igorbarato, DamienMcKenna: Promotion start date...

Issue #3209414 by bsuttis, igorbarato, DamienMcKenna: Promotion start date default value doesn't respect time zone.
parent 0312d4a2
Loading
Loading
Loading
Loading
+2 −2
Changes for composer.json: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@
    "name": "drupal/commerce",
    "type": "drupal-module",
    "description": "Drupal Commerce is a flexible eCommerce solution.",
    "homepage": "http://drupal.org/project/commerce",
    "license": "GPL-2.0+",
    "homepage": "https://drupal.org/project/commerce",
    "license": "GPL-2.0-or-later",
    "require": {
        "php": "^7.3 || ^8.0",
        "ext-bcmath": "*",
+1 −1
Changes for modules/promotion/src/Entity/Promotion.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -928,7 +928,7 @@ class Promotion extends CommerceContentEntityBase implements PromotionInterface
   */
  public static function getDefaultStartDate() {
    $timestamp = \Drupal::time()->getRequestTime();
    return gmdate(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $timestamp);
    return date(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $timestamp);
  }

  /**
+1 −1
Changes for modules/promotion/tests/src/Kernel/Entity/CouponTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ class CouponTest extends OrderKernelTestBase {

    $date_pattern = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
    $time = $this->container->get('datetime.time');
    $default_start_date = gmdate($date_pattern, $time->getRequestTime());
    $default_start_date = date($date_pattern, $time->getRequestTime());
    $this->assertEquals($default_start_date, $coupon->getStartDate()->format($date_pattern));
    $coupon->setStartDate(new DrupalDateTime('2017-01-01 12:12:12'));
    $this->assertEquals('2017-01-01 12:12:12 UTC', $coupon->getStartDate()->format('Y-m-d H:i:s T'));
+1 −1
Changes for modules/promotion/tests/src/Kernel/Entity/PromotionTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ class PromotionTest extends OrderKernelTestBase {

    $date_pattern = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
    $time = $this->container->get('datetime.time');
    $default_start_date = gmdate($date_pattern, $time->getRequestTime());
    $default_start_date = date($date_pattern, $time->getRequestTime());
    $this->assertEquals($default_start_date, $promotion->getStartDate()->format($date_pattern));
    $promotion->setStartDate(new DrupalDateTime('2017-01-01 12:12:12'));
    $this->assertEquals('2017-01-01 12:12:12 UTC', $promotion->getStartDate()->format('Y-m-d H:i:s T'));