1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 06:50:50 +00:00

Wikibase: Do not escape and repeat calendar data

This commit is contained in:
gnosygnu 2016-11-10 12:00:45 -05:00
parent 0f8d0257c9
commit d2d58f2b7e
3 changed files with 11 additions and 17 deletions

View File

@ -71,15 +71,8 @@ public class Wbase_claim_time extends Wbase_claim_base {
public void Write_to_bfr(Bry_bfr bfr, Bry_bfr tmp_time_bfr, Bry_fmtr tmp_time_fmtr, Wdata_hwtr_msgs msgs, byte[] ttl) { public void Write_to_bfr(Bry_bfr bfr, Bry_bfr tmp_time_bfr, Bry_fmtr tmp_time_fmtr, Wdata_hwtr_msgs msgs, byte[] ttl) {
try { try {
Wbase_date date = this.Time_as_date(); Wbase_date date = this.Time_as_date();
boolean calendar_is_julian = this.Calendar_is_julian(); if (this.Calendar_is_julian()) date = Wbase_date_.To_julian(date);
byte[] calendar_display = null;
if (calendar_is_julian) {
date = Wbase_date_.To_julian(date);
calendar_display = msgs.Time_julian();
}
Wbase_date_.To_bfr(bfr, tmp_time_fmtr, tmp_time_bfr, msgs, date); Wbase_date_.To_bfr(bfr, tmp_time_fmtr, tmp_time_bfr, msgs, date);
if (calendar_display != null)
bfr.Add_byte_space().Add(calendar_display);
} catch (Exception e) { } catch (Exception e) {
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to write time; ttl=~{0} pid=~{1} err=~{2}", ttl, this.Pid(), Err_.Message_gplx_log(e)); Xoa_app_.Usr_dlg().Warn_many("", "", "failed to write time; ttl=~{0} pid=~{1} err=~{2}", ttl, this.Pid(), Err_.Message_gplx_log(e));
} }
@ -87,14 +80,8 @@ public class Wbase_claim_time extends Wbase_claim_base {
public static void Write_to_bfr(Bry_bfr bfr, Bry_bfr tmp_time_bfr, Bry_fmtr tmp_time_fmtr, Wdata_hwtr_msgs msgs public static void Write_to_bfr(Bry_bfr bfr, Bry_bfr tmp_time_bfr, Bry_fmtr tmp_time_fmtr, Wdata_hwtr_msgs msgs
, byte[] ttl, byte[] pid, Wbase_date date, boolean calendar_is_julian) { , byte[] ttl, byte[] pid, Wbase_date date, boolean calendar_is_julian) {
try { try {
byte[] calendar_display = null; if (calendar_is_julian) date = Wbase_date_.To_julian(date);
if (calendar_is_julian) {
date = Wbase_date_.To_julian(date);
calendar_display = msgs.Time_julian();
}
Wbase_date_.To_bfr(bfr, tmp_time_fmtr, tmp_time_bfr, msgs, date); Wbase_date_.To_bfr(bfr, tmp_time_fmtr, tmp_time_bfr, msgs, date);
if (calendar_display != null)
bfr.Add_byte_space().Add(calendar_display);
} catch (Exception e) { } catch (Exception e) {
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to write time; ttl=~{0} pid=~{1} err=~{2}", ttl, pid, Err_.Message_gplx_log(e)); Xoa_app_.Usr_dlg().Warn_many("", "", "failed to write time; ttl=~{0} pid=~{1} err=~{2}", ttl, pid, Err_.Message_gplx_log(e));
} }

View File

@ -222,7 +222,7 @@ public class Wdata_hwtr_msgs {
int len = ids.length; int len = ids.length;
byte[][] rv = new byte[len][]; byte[][] rv = new byte[len][];
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
rv[i] = gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(msg_mgr.Val_by_key_obj(ids[i])); rv[i] = msg_mgr.Val_by_key_obj(ids[i]); // TOMBSTONE: do not call "Gfh_utl.Escape_html_as_bry" else "<sup>jul</sup>" will be rendered literally; PAGE:wd:Q2 DATE:2016-11-10
return rv; return rv;
} }
private static byte[] Name_(byte[] v) {return Bry_.Ucase__1st(Bry_.Copy(v));} private static byte[] Name_(byte[] v) {return Bry_.Ucase__1st(Bry_.Copy(v));}

View File

@ -34,6 +34,13 @@ public class Wdata_visitor__html_wtr_tst {
, "4:05:06 3 Feb 2001" , "4:05:06 3 Feb 2001"
); );
} }
@Test public void Time__julian() {
fxt
.Test_claim_val
( fxt.Wdata_fxt().Make_claim_time(1, "2001-02-03 04:05:06", Bry_.Empty, Bry_.new_a7("http://www.wikidata.org/entity/Q1985786"))
, "4:05:06 25 Feb 2001<sup>jul</sup>" // NOTE: "Feb 3" is "Feb 25" in julian time
);
}
@Test public void Quantity_ubound_lbound() { @Test public void Quantity_ubound_lbound() {
fxt fxt
.Test_claim_val .Test_claim_val