Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bootstrap_datetime_picker
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
bootstrap_datetime_picker
Commits
6e276420
Commit
6e276420
authored
4 years ago
by
git
Committed by
Prashant Chauhan
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3084585
by Sergiu Stici: Deprecated Code Report
parent
2f91787c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Field/FieldWidget/BootstrapDateTimeWidget.php
+8
-7
8 additions, 7 deletions
src/Plugin/Field/FieldWidget/BootstrapDateTimeWidget.php
with
8 additions
and
7 deletions
src/Plugin/Field/FieldWidget/BootstrapDateTimeWidget.php
+
8
−
7
View file @
6e276420
...
...
@@ -11,6 +11,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\datetime\Plugin\Field\FieldWidget\DateTimeWidgetBase
;
use
Drupal\datetime\Plugin\Field\FieldType\DateTimeItem
;
use
Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface
;
/**
* Plugin implementation of the BootstrapDateTimeWidget widget.
...
...
@@ -143,17 +144,17 @@ class BootstrapDateTimeWidget extends DateTimeWidgetBase implements ContainerFac
case
DateTimeItem
::
DATETIME_TYPE_DATE
:
// If this is a date-only field, set it to the default time so the
// timezone conversion can be reversed.
date
time_date_default_time
(
$date
);
$format
=
D
ATETIME_
DATE_STORAGE_FORMAT
;
$
date
->
setDefaultDateTime
(
);
$format
=
D
ateTimeItemInterface
::
DATE_STORAGE_FORMAT
;
break
;
default
:
$format
=
D
ATETIME_
DATETIME_STORAGE_FORMAT
;
$format
=
D
ateTimeItemInterface
::
DATETIME_STORAGE_FORMAT
;
break
;
}
// Adjust the date for storage.
$date
->
setTimezone
(
new
\DateTimezone
(
D
ATETIME_
STORAGE_TIMEZONE
));
$date
->
setTimezone
(
new
\DateTimezone
(
D
ateTimeItemInterface
::
STORAGE_TIMEZONE
));
$item
[
'value'
]
=
$date
->
format
(
$format
);
}
...
...
@@ -212,10 +213,10 @@ class BootstrapDateTimeWidget extends DateTimeWidgetBase implements ContainerFac
case
DateTimeItem
::
DATETIME_TYPE_DATE
:
// A date-only field should have no timezone conversion performed, so
// use the same timezone as for storage.
$element
[
'value'
][
'#date_timezone'
]
=
D
ATETIME_
STORAGE_TIMEZONE
;
$element
[
'value'
][
'#date_timezone'
]
=
D
ateTimeItemInterface
::
STORAGE_TIMEZONE
;
// If field is date only, use default time format.
$format
=
D
ATETIME_
DATE_STORAGE_FORMAT
;
$format
=
D
ateTimeItemInterface
::
DATE_STORAGE_FORMAT
;
// Type of the field.
$element
[
'value'
][
'#date_type'
]
=
$this
->
getFieldSetting
(
'datetime_type'
);
...
...
@@ -239,7 +240,7 @@ class BootstrapDateTimeWidget extends DateTimeWidgetBase implements ContainerFac
if
(
$this
->
getFieldSetting
(
'datetime_type'
)
==
DateTimeItem
::
DATETIME_TYPE_DATE
)
{
// A date without time will pick up the current time, use the default
// time.
date
time_date_default_time
(
$date
);
$
date
->
setDefaultDateTime
(
);
}
$date
->
setTimezone
(
new
\DateTimeZone
(
$element
[
'value'
][
'#date_timezone'
]));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment