| | @@ -931,10 +931,21 @@ |
| 931 | 931 | } |
| 932 | 932 | if( modulo ) code = code - (code % modulo); |
| 933 | 933 | return code; |
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | + |
| 937 | +/* |
| 938 | +** Convenience routine which converts a Julian time value into a Unix |
| 939 | +** Epoch timestamp. Requires the db, so this cannot be used before the |
| 940 | +** repo is opened (will trigger a fatal error in db_xxx()). |
| 941 | +*/ |
| 942 | +static cson_value * json_julian_to_timestamp(double j){ |
| 943 | + return cson_value_new_integer((cson_int_t) |
| 944 | + db_int64(0,"SELECT strftime('%%s',%lf)",j) |
| 945 | + ); |
| 946 | +} |
| 936 | 947 | |
| 937 | 948 | /* |
| 938 | 949 | ** Creates a new Fossil/JSON response envelope skeleton. It is owned |
| 939 | 950 | ** by the caller, who must eventually free it using cson_value_free(), |
| 940 | 951 | ** or add it to a cson container to transfer ownership. Returns NULL |
| | @@ -1567,18 +1578,11 @@ |
| 1567 | 1578 | cson_object_set(pay,"version",json_new_string(pWiki->zBaseline)) |
| 1568 | 1579 | /*FIXME: pWiki->zBaseline is NULL. How to get the version number?*/ |
| 1569 | 1580 | ; |
| 1570 | 1581 | cson_object_set(pay,"rid",cson_value_new_integer((cson_int_t)rid)); |
| 1571 | 1582 | cson_object_set(pay,"lastSavedBy",json_new_string(pWiki->zUser)); |
| 1572 | | - cson_object_set(pay,"timestamp", |
| 1573 | | - cson_value_new_integer((cson_int_t) |
| 1574 | | - db_int64(0, |
| 1575 | | - "SELECT strftime('%%s',%lf)", |
| 1576 | | - pWiki->rDate |
| 1577 | | - ) |
| 1578 | | - ) |
| 1579 | | - ); |
| 1583 | + cson_object_set(pay,"timestamp", json_julian_to_timestamp(pWiki->rDate)); |
| 1580 | 1584 | cson_object_set(pay,"contentLength",cson_value_new_integer((cson_int_t)len)); |
| 1581 | 1585 | cson_object_set(pay,"contentFormat",json_new_string(doParse?"html":"raw")); |
| 1582 | 1586 | cson_object_set(pay,"content",cson_value_new_string(zBody,len)); |
| 1583 | 1587 | /*TODO: add 'T' (tag) fields*/ |
| 1584 | 1588 | /*TODO: add the 'A' card (file attachment) entries?*/ |
| 1585 | 1589 | |