FunctionDaysInMonthLibrary "FunctionDaysInMonth"
Method to find the number of days in a given month of year.
days_in_month(year, month) Method to find the number of days in a given month of year.
Parameters:
year : int, year of month, so we know if year is a leap year or not.
month : int, month number.
Returns: int
Formatting
SignificantFiguresLibrary "SignificantFigures"
sigFig(float _float, int _figures)
@description Takes a floating-point number - one that can, but doesn't have to, include a decimal point - and converts it to a floating-point number with only a certain number of digits left. For example, say you want to display a variable from your script to the user and it comes out to something like 45.366666666666666666666667 or whatever. That looks awful when you, for example, print it in a label. Now you could round it up to the nearest integer easily using a built-in function, or even to a certain number of decimal places using a reasonably simple custom function. But that's a bit arbitrary. Suppose you don't know what asset the script will be used on, and so you can't predict what the price is, and what the value will turn out to be. It could be 0.00045366666666666666666666667 instead. Now if you round it up to 3 decimal places it comes out as 0.000, which is useless. My function will round that number to 0.0004536 instead, if told to do it to 4 significant digits.
I think this is more friendly.
@function Converts float with arbitrary number of digits to one with a specified number of significant figures.
@param float _float is the floating-point number to manipulate.
@param int _figures is the number of significant figures you want.
@returns Returns a float with the specified number of significant figures
FunctionDatestringLibrary "FunctionDatestring"
Methods to stringify date/time, altho there is already builtin support for it.
datetime(unixtime) a stringified date stamp at specified unix time.
Parameters:
unixtime : int unix timestamp.
Returns: string
date_(unixtime) a stringified date stamp at specified unix time.
Parameters:
unixtime : int unix timestamp.
Returns: string
time_(unixtime) a stringified date stamp at specified unix time.
Parameters:
unixtime : int unix timestamp.
Returns: string