[LIVECOPY-304] Change timezone for Push & Publish in "Push master changes" Created: 07/Feb/22 Updated: 11/Aug/23 |
|
| Status: | Open |
| Project: | Live Copy |
| Component/s: | None |
| Affects Version/s: | 3.2.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Neutral |
| Reporter: | Annick Boehler | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoR: |
Empty
|
| Date of First Response: | |
| Epic Link: | AuthorX Maintenance |
| Team: |
| Comments |
| Comment by Minh Nguyen [ 08/Feb/22 ] |
|
Per my investigation, the action "Push master changes" was implemented by its own live copy version. I checked the code inĀ info.magnolia.livecopy.actions.PublishChooser
dateField.addValueChangeListener((event) -> {
Map<String, Object> data = (Map)this.liveCopyContext.getData().value().orElse(new HashMap());
data.put("publicationDate", ((LocalDateTime)event.getValue()).toString());
this.liveCopyContext.getData().set(data);
});
In normal form, we will use DateFieldFactory to
@Override
protected Component createFieldComponent() {
AbstractDateField field;
if (getDefinition().isTime()) {
field = new DateTimeField();
} else {
field = new DateField();
}
if (getDefinition().isTime()) {
field.setDateFormat(getDefinition().getDateFormat() + " " + getDefinition().getTimeFormat());
field.setResolution(DateTimeResolution.SECOND);
} else {
field.setDateFormat(getDefinition().getDateFormat());
}
setTimeZoneInfo(field);
return field;
}
private void setTimeZoneInfo(AbstractDateField field) {
final String prefix = i18n.translate("ui-admincentral.dateField.timeZone.label");
final ZoneId zoneId = TimezoneUtil.getUserZoneId(user);
final String shortId = TimezoneUtil.getTimeZoneInfo(user, TimeZone.SHORT);
final String longId = TimezoneUtil.getTimeZoneInfo(user, TimeZone.LONG);
field.setZoneId(zoneId);
field.setDescription(prefix + " " + longId);
if (field instanceof DateField) {
((DateField) field).setPlaceholder(prefix + " " + shortId);
} else {
((DateTimeField) field).setPlaceholder(prefix + " " + shortId);
}
then DateConverter
@Override
public Result<Object> convertToModel(Temporal value, ValueContext valueContext) { // Temporal (LocalDate or LocalDateTime) to Date
if (value instanceof LocalDate) {
return Result.ok(Date.from(((LocalDate) value).atStartOfDay(TimezoneUtil.getUserZoneId(user)).toInstant()));
}
return Result.ok(Optional.ofNullable(value)
.map(nonNullDateTime -> Date.from(((LocalDateTime) nonNullDateTime).atZone(TimezoneUtil.getUserZoneId(user)).toInstant()))
.orElse(null));
}
Thank you so much. |
| Comment by Annick Boehler [ 11/Aug/23 ] |
|
Hi Livecopy team, is there any update on this? Any timeline when you will be able to work on this? Thanks for a short udpate. |