Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Frontend
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
813
Issues
813
List
Boards
Labels
Service Desk
Milestones
Merge Requests
47
Merge Requests
47
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
b6cd5641
Commit
b6cd5641
authored
56 minutes ago
by
Marcelo Rivera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix): timezones issues with dates
parent
5bea1a96
goal/boost-campaigns-e24
1 merge request
!387
WIP: Boost Campaigns (&24)
Pipeline
#71739094
passed with stages
in 28 minutes and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
datetimepicker.directive.ts
...pp/common/directives/material/datetimepicker.directive.ts
+18
-4
creator.component.html
...pp/modules/boost/campaigns/creator/creator.component.html
+3
-2
No files found.
src/app/common/directives/material/datetimepicker.directive.ts
View file @
b6cd5641
import
{
Directive
,
EventEmitter
,
HostListener
,
Input
,
Output
}
from
'
@angular/core
'
;
import
{
DatePipe
}
from
'
@angular/common
'
;
import
{
default
as
DateTimePicker
}
from
'
material-datetime-picker
'
;
import
*
as
moment
from
"
moment
"
;
@
Directive
({
selector
:
'
[mdl-datetime-picker]
'
,
providers
:
[
DatePipe
]
})
export
class
MaterialDateTimePickerDirective
{
@
Input
()
date
;
@
Input
()
dateFormat
:
string
=
'
MM/DD/YY, h:mm
'
;
@
Input
()
useUTC
:
boolean
=
false
;
@
Output
()
dateChange
:
EventEmitter
<
any
>
=
new
EventEmitter
<
any
>
();
private
open
:
boolean
=
false
;
private
picker
;
constructor
(
public
datePipe
:
DatePipe
)
{
}
readonly
DEFAULT_FORMAT
=
'
MM/DD/YY, h:mm
'
;
@
HostListener
(
'
click
'
)
@
HostListener
(
'
keydown.enter
'
)
...
...
@@ -27,7 +28,20 @@ export class MaterialDateTimePickerDirective {
}
private
submitCallback
(
value
)
{
this
.
dateChange
.
emit
(
this
.
datePipe
.
transform
(
value
.
format
(),
'
short
'
));
let
formatted
;
if
(
this
.
useUTC
)
{
// get date without timezone
const
noTimezone
=
value
.
format
(
this
.
DEFAULT_FORMAT
);
// create a new UTC moment with the noTimezone date
const
withTimezone
=
moment
.
utc
(
noTimezone
,
this
.
DEFAULT_FORMAT
);
// get UTC date
formatted
=
withTimezone
.
format
(
this
.
dateFormat
);
}
else
{
formatted
=
value
.
format
(
this
.
dateFormat
);
}
this
.
dateChange
.
emit
(
formatted
);
this
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/boost/campaigns/creator/creator.component.html
View file @
b6cd5641
...
...
@@ -134,10 +134,11 @@
<div
class=
"m-date-selector--input"
mdl-datetime-picker
[
dateFormat
]="'
MM
/
DD
/
YY
,
h:mm
a
Z
'"
[
useUTC
]="
true
"
[
date
]="
campaign
.
start
"
(
dateChange
)="
onStartDateChange
($
event
);
triggerPreview
()"
>
<input
id=
"boost-creator__start"
type=
"text"
placeholder=
"Now"
i18n
[
value
]="
campaign
.
start
|
date:
'
MMM
dd
'"
readonly
>
<input
id=
"boost-creator__start"
type=
"text"
placeholder=
"Now"
i18n
[
value
]="
campaign
.
start
|
utcDate
|
date:
'
MMM
dd
'"
readonly
>
<i
class=
"material-icons"
>
keyboard_arrow_down
</i>
</div>
</div>
...
...
@@ -153,7 +154,7 @@
mdl-datetime-picker
[
date
]="
campaign
.
end
"
(
dateChange
)="
onEndDateChange
($
event
);
triggerPreview
()"
>
<input
id=
"boost-creator__end"
type=
"text"
placeholder=
"End of times"
i18n
[
value
]="
campaign
.
end
|
date:
'
MMM
dd
'"
readonly
>
<input
id=
"boost-creator__end"
type=
"text"
placeholder=
"End of times"
i18n
[
value
]="
campaign
.
end
|
utcDate
|
date:
'
MMM
dd
'"
readonly
>
<i
class=
"material-icons"
>
keyboard_arrow_down
</i>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment