historical_age

From Kolmafia
Revision as of 15:06, 31 December 2020 by Philmasterplus (talk | contribs) (Convert to Template:Function2 format, use Template:SeeAlso/Mall Prices, add JS sample code)
Jump to navigation Jump to search

Function Syntax

float historical_ageitem shop_for )

Returns the age of the price returned by historical_age() in days.
  • shop_for: Item to check for

The return value is in days. For example, a return value of 0.5 means that the price is 12 hours old.

Code Samples

This function returns a price no more than 18 hours old by checking mall_price() if historical_price() is older than that.

ASH JavaScript
int check_price( item shopfor ) {
   if ( historical_age( shopfor ) > .75 )
      return mall_price( shopfor );
   return historical_price( shopfor );
}
const { historicalAge, historicalPrice, mallPrice } = require("kolmafia");

function checkPrice(shopfor) {
  if (historicalAge(shopfor) > .75)
    return mallPrice(shopfor);
  return historicalPrice(shopfor);
}

See Also

historical_age() | historical_price() | mall_price() | mall_prices()