mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
ADD-TIME64-API: libgnucash/engine/gnc-pricedb.[ch]
This commit is contained in:
@@ -517,6 +517,27 @@ gnc_price_set_time(GNCPrice *p, Timespec t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gnc_price_set_time64(GNCPrice *p, time64 t64)
|
||||||
|
{
|
||||||
|
if (!p) return;
|
||||||
|
if (p->tmspec.tv_sec != t64) // do we need to check nsec as well?
|
||||||
|
{
|
||||||
|
/* Changing the datestamp requires the hash table
|
||||||
|
* position to be modified. The easiest way of doing
|
||||||
|
* this is to remove and reinsert. */
|
||||||
|
gnc_price_ref (p);
|
||||||
|
remove_price (p->db, p, FALSE);
|
||||||
|
gnc_price_begin_edit (p);
|
||||||
|
p->tmspec.tv_sec = t64;
|
||||||
|
p->tmspec.tv_nsec = 0;
|
||||||
|
gnc_price_set_dirty(p);
|
||||||
|
gnc_price_commit_edit (p);
|
||||||
|
add_price (p->db, p);
|
||||||
|
gnc_price_unref (p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_price_set_source(GNCPrice *p, PriceSource s)
|
gnc_price_set_source(GNCPrice *p, PriceSource s)
|
||||||
{
|
{
|
||||||
@@ -2258,6 +2279,18 @@ gnc_pricedb_lookup_day(GNCPriceDB *db,
|
|||||||
return lookup_nearest_in_time(db, c, currency, t, TRUE);
|
return lookup_nearest_in_time(db, c, currency, t, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNCPrice *
|
||||||
|
gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
|
||||||
|
const gnc_commodity *c,
|
||||||
|
const gnc_commodity *currency,
|
||||||
|
time64 t64)
|
||||||
|
{
|
||||||
|
Timespec t;
|
||||||
|
t.tv_sec = t64;
|
||||||
|
t.tv_nsec = 0;
|
||||||
|
return lookup_nearest_in_time(db, c, currency, t, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
GNCPrice *
|
GNCPrice *
|
||||||
gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||||
const gnc_commodity *c,
|
const gnc_commodity *c,
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ void gnc_price_commit_edit (GNCPrice *p);
|
|||||||
void gnc_price_set_commodity(GNCPrice *p, gnc_commodity *c);
|
void gnc_price_set_commodity(GNCPrice *p, gnc_commodity *c);
|
||||||
void gnc_price_set_currency(GNCPrice *p, gnc_commodity *c);
|
void gnc_price_set_currency(GNCPrice *p, gnc_commodity *c);
|
||||||
void gnc_price_set_time(GNCPrice *p, Timespec t);
|
void gnc_price_set_time(GNCPrice *p, Timespec t);
|
||||||
|
void gnc_price_set_time64(GNCPrice *p, time64 t64);
|
||||||
void gnc_price_set_source(GNCPrice *p, PriceSource source);
|
void gnc_price_set_source(GNCPrice *p, PriceSource source);
|
||||||
void gnc_price_set_source_string(GNCPrice *p, const char* s);
|
void gnc_price_set_source_string(GNCPrice *p, const char* s);
|
||||||
void gnc_price_set_typestr(GNCPrice *p, const char* type);
|
void gnc_price_set_typestr(GNCPrice *p, const char* type);
|
||||||
@@ -495,6 +496,10 @@ GNCPrice * gnc_pricedb_lookup_day(GNCPriceDB *db,
|
|||||||
const gnc_commodity *currency,
|
const gnc_commodity *currency,
|
||||||
Timespec t);
|
Timespec t);
|
||||||
|
|
||||||
|
GNCPrice * gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
|
||||||
|
const gnc_commodity *commodity,
|
||||||
|
const gnc_commodity *currency,
|
||||||
|
time64 t64);
|
||||||
|
|
||||||
/** @brief Return the price between the two commoditiesz nearest to the given
|
/** @brief Return the price between the two commoditiesz nearest to the given
|
||||||
* time.
|
* time.
|
||||||
|
|||||||
Reference in New Issue
Block a user