diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 2786774..13b65ab 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -837,11 +837,6 @@ function template_preprocess_time(&$variables) {
       $variables['html'] = FALSE;
     }
   }
-
-  // Add a 'datetime' class.
-  $variables['attributes']['class'][] = 'datetime';
-
-  $variables['attributes'] = new Attribute($variables['attributes']);
 }
 
 /**
@@ -870,7 +865,6 @@ function template_preprocess_datetime_form(&$variables) {
   if (!empty($element['#attributes']['class'])) {
     $variables['attributes']['class'] = (array) $element['#attributes']['class'];
   }
-  $variables['attributes']['class'][] = 'container-inline';
 
   $variables['content'] = $element;
 }
@@ -896,13 +890,12 @@ function template_preprocess_datetime_wrapper(&$variables) {
     $variables['description'] = $element['#description'];
   }
 
-  $title_attributes = array('class' => array('label'));
+  $variables['required'] = FALSE;
   // For required datetime fields a 'form-required' class is appended to the
   // label attributes.
   if (!empty($element['#required'])) {
-    $title_attributes['class'][] = 'form-required';
+    $variables['required'] = TRUE;
   }
-  $variables['title_attributes'] = new Attribute($title_attributes);
   $variables['content'] = $element['#children'];
 }
 
diff --git a/core/modules/system/templates/datetime-form.html.twig b/core/modules/system/templates/datetime-form.html.twig
index fef4b5e..bf31668 100644
--- a/core/modules/system/templates/datetime-form.html.twig
+++ b/core/modules/system/templates/datetime-form.html.twig
@@ -12,6 +12,6 @@
  * @ingroup themeable
  */
 #}
-<div{{ attributes }}>
+<div{{ attributes.addClass('container-inline') }}>
   {{ content }}
 </div>
diff --git a/core/modules/system/templates/datetime-wrapper.html.twig b/core/modules/system/templates/datetime-wrapper.html.twig
index 5660cf5..9f70d49 100644
--- a/core/modules/system/templates/datetime-wrapper.html.twig
+++ b/core/modules/system/templates/datetime-wrapper.html.twig
@@ -14,8 +14,14 @@
  * @ingroup themeable
  */
 #}
+{%
+  set title_classes = [
+    'label',
+    required ? 'form-required',
+  ]
+%}
 {% if title %}
-  <h4{{ title_attributes }}>{{ title }}</h4>
+  <h4{{ title_attributes.addClass(title_classes) }}>{{ title }}</h4>
 {% endif %}
 {{ content }}
 {% if description %}
diff --git a/core/modules/system/templates/time.html.twig b/core/modules/system/templates/time.html.twig
index 183b834..521df56 100644
--- a/core/modules/system/templates/time.html.twig
+++ b/core/modules/system/templates/time.html.twig
@@ -25,4 +25,4 @@
  * @see http://www.w3.org/TR/html5-author/the-time-element.html#attr-time-datetime
  */
 #}
-<time{{ attributes }}>{{ html ? text|raw : text }}</time>
+<time{{ attributes.addClass('datetime') }}>{{ html ? text|raw : text }}</time>
