mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Category: Parse year as yyyy not YYYY [#664]
This commit is contained in:
parent
775bff3bac
commit
3e9bc6d93a
@ -34,7 +34,7 @@ class Xob_catlink_mgr {
|
||||
public void On_cmd_row(int page_id, byte[] ctg_ttl, byte[] sortkey_orig, byte[] timestamp_bry, byte[] sortkey_prefix, byte[] collation_bry, byte[] type_bry) {
|
||||
// convert strings to numbers
|
||||
String timestamp_str = String_.new_u8(timestamp_bry);
|
||||
long timestamp = String_.Len_eq_0(timestamp_str) ? 0 : DateAdp_.parse_fmt(timestamp_str, "YYYY-MM-dd HH:mm:ss").Timestamp_unix();
|
||||
long timestamp = Parse_timestamp(timestamp_str);
|
||||
byte collation_id = collation_enum.To_tid_or_fail(collation_bry);
|
||||
byte type_id = type_enum.To_tid_or_fail(type_bry);
|
||||
|
||||
@ -54,6 +54,9 @@ class Xob_catlink_mgr {
|
||||
tmp_conn.Txn_sav();
|
||||
}
|
||||
}
|
||||
public static long Parse_timestamp(String val) {
|
||||
return String_.Len_eq_0(val) ? 0 : DateAdp_.parse_fmt(val, "yyyy-MM-dd HH:mm:ss").Timestamp_unix();
|
||||
}
|
||||
public void On_cmd_end() {
|
||||
tmp_link_tbl.Insert_end();
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.wikis.ctgs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xob_catlink_mgr__tst {
|
||||
private final Xob_catlink_mgr__fxt fxt = new Xob_catlink_mgr__fxt();
|
||||
@Test public void Parse_timestamp() {
|
||||
fxt.Test__Parse_timestamp("2016-02-01 18:34:08", 1454351648); // fails if 1451241248
|
||||
}
|
||||
}
|
||||
class Xob_catlink_mgr__fxt {
|
||||
public void Test__Parse_timestamp(String raw, long expd) {
|
||||
long actl = Xob_catlink_mgr.Parse_timestamp(raw);
|
||||
Gftest.Eq__long(expd, actl);
|
||||
|
||||
DateAdp date = DateAdp_.unixtime_utc_seconds_(actl);
|
||||
Gftest.Eq__str(raw, date.XtoStr_fmt("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user