Skip to content

Commit

Permalink
getTimeZoneDisplay
Browse files Browse the repository at this point in the history
localized display values for LMT and LTST tzids (#561)
  • Loading branch information
forrestguice committed Feb 20, 2022
1 parent e12d7bf commit 28b149f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,12 @@ protected void updateTimeText(@NonNull SuntimesRiseSetDataset data)
}

SuntimesUtils.TimeDisplayText timeText = utils.calendarDateTimeDisplayString(context, mapTime);
if (sunTime != null) {
if (sunTime != null)
{
String tzDisplay = WidgetTimezones.getTimeZoneDisplay(context, mapTime.getTimeZone());
if (suffix.isEmpty())
sunTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), mapTime.getTimeZone().getID()));
else sunTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), mapTime.getTimeZone().getID(), suffix), suffix, color_warning));
sunTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), tzDisplay));
else sunTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), tzDisplay, suffix), suffix, color_warning));
}

if (offsetTime != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ protected void updateViews( Context context )
new SuntimesUtils.ImageSpanTag(SuntimesUtils.SPANTAG_DST, dstWarningIcon)
};

String timezoneString = getString(R.string.timezoneField, timezone.getID());
String timezoneString = getString(R.string.timezoneField, WidgetTimezones.getTimeZoneDisplay(context, timezone));
SpannableStringBuilder timezoneSpan = SuntimesUtils.createSpan(this, timezoneString, timezoneTags);
txt_timezone.setText(timezoneSpan);
txt_timezone.setContentDescription(timezoneString.replaceAll(Pattern.quote(SuntimesUtils.SPANTAG_WARNING), "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,12 @@ private void updateTimeText()
}

SuntimesUtils.TimeDisplayText timeText = utils.calendarDateTimeDisplayString(context, mapTime);
if (utcTime != null) {
if (utcTime != null)
{
String tzDisplay = WidgetTimezones.getTimeZoneDisplay(context, mapTime.getTimeZone());
if (suffix.isEmpty())
utcTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), mapTime.getTimeZone().getID()));
else utcTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), mapTime.getTimeZone().getID(), suffix), suffix, color_warning));
utcTime.setText(getString(R.string.datetime_format_verylong, timeText.toString(), tzDisplay));
else utcTime.setText(SuntimesUtils.createBoldColorSpan(null, getString(R.string.datetime_format_verylong1, timeText.toString(), tzDisplay, suffix), suffix, color_warning));
}

SuntimesUtils.TimeDisplayText offsetText = utils.timeDeltaLongDisplayString(nowMillis, mapTimeMillis, false, true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ public static TimeZone getTimeZone(String tzId, @Nullable Double longitude)
}
}

public static String getTimeZoneDisplay(Context context, TimeZone tz) {
if (tz != null)
{
switch (tz.getID())
{
case LocalMeanTime.TIMEZONEID: return context.getString(R.string.time_localMean);
case ApparentSolarTime.TIMEZONEID: return context.getString(R.string.time_apparent);
default: return tz.getID();
}
} else return "";
}

///////////////////////////////////////
///////////////////////////////////////

Expand Down

0 comments on commit 28b149f

Please sign in to comment.