c_ws_plugin__s2member_utils_time
public class c_ws_plugin__s2member_utils_time
3.5
( 5 Methods ) Method Summary | |
|---|---|
| public static str | amount_period_term(int|str $amount, str $period_term, bool|int|str $recurring) Converts a Billing Amount, Period Term, and Recurring flag. |
| public static str | approx_time_difference(int $from, int $to) Determines the difference between two timestamps. |
| public static int | auto_eot_time(int|str $user_id, str $period1, str $period3, str $eotper, int $lpt, int $ext) Calculate Auto-EOT Time, based on |
| public static str | period_term(str $period_term, bool|int|str $recurring) Converts a "Period Term", and Recurring flag. |
| public static str|bool | term_cycle(str $term_or_period_term, str $directive) Converts a Term |
public static str amount_period_term(int|str $amount, str $period_term, bool|int|str $recurring)
Converts a Billing Amount, Period Term, and Recurring flag.
Returns a full Billing Term explanation.
Example: 1.00 for 2 months.
3.5
int|str $amount - A numeric amount, usually in US dollars.
str $period_term - A "Period Term" combo, with space separation.
bool|int|str $recurring - Defaults to false. If true, the $period_term is recurring. Can also be the string 0|1|BN.
str - Verbose (lowercase) Amount Period Term description ( i.e. 1.00, 1.00 / monthly, 1.00 every 3 months, 1.00 for 1 month, 1.00 for 3 months, etc. ).
Add support here for fixed recurring payments configured through rrt="".
public static str approx_time_difference(int $from, int $to)
Determines the difference between two timestamps.
Returns the difference in a human readable format.
Supports: minutes, hours, days, weeks, months, and years. This is an improvement on WordPress® human_time_diff().
This returns an "approximate" time difference. Rounded to the nearest minute, hour, day, week, month, year.
3.5
int $from - Beginning timestamp to start from.
int $to - Ending timestamp to stop at.
str - Human readable difference between $from and $to.
public static int auto_eot_time(int|str $user_id, str $period1, str $period3, str $eotper, int $lpt, int $ext)
Calculate Auto-EOT Time, based on user_id, period1, period3, last_payment_time, or an optional eotper.
Used by s2Member's built-in Auto-EOT System, and also by its IPN routines.
last_payment_time can be forced w/ $lpt (i.e. for delayed eots).
3.5
int|str $user_id - Optional. A WordPress® User ID.
str $period1 - Optional. First Intial "Period Term" ( i.e. 0 D ). Only used when $user_id is passed in.
str $period3 - Optional. Regular "Period Term" ( i.e. 1 M ). Only used when $user_id is passed in.
str $eotper - Optional. A Fixed "Period Term" ( i.e. 1 M ). This replaces $period1 / $period3. Not used when $user_id is passed in. Only when $user_id is not passed in.
int $lpt - Optional. Force feed the Last Payment Time. Only used when $user_id is passed in.
int $ext - Optional. Existing EOT Time for the User. Always considered; even when $user_id is not passed in. But only when $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_time_ext_behavior"] === "extend".
int - Unix timestamp indicating the EOT Time calculated by this routine.
public static str period_term(str $period_term, bool|int|str $recurring)
Converts a "Period Term", and Recurring flag.
Returns a full Term explanation (lowercase).
Example: 2 months.
3.5
str $period_term - A "Period Term" combination.
bool|int|str $recurring - Defaults to false. If true, the $period_term is recurring. Can also be the string 0|1|BN.
str - Verbose (lowercase) Period Term description ( i.e. weekly, every 3 weeks, lifetime, 3 months, 1 month, etc. ).
Add support here for fixed recurring payments configured through rrt="".
public static str|bool term_cycle(str $term_or_period_term, str $directive)
Converts a Term [D,W,M,Y,L,Day,Week,Month,Year,Lifetime] into Daily, Weekly, Monthly, Yearly, Lifetime.
Can also handle "Period Term" combinations. Where the Period will be stripped automatically before conversion.
For example, 1 D, would become, just Daily. Another example, 3 Y would become Yearly; and 1 L, would become Lifetime.
Recurring examples: 2 W, becomes Bi-Weekly, 3 M becomes Quarterly, and 2 M becomes Bi-Monthly.
3.5
str $term_or_period_term - A Term, or a "Period Term" combination.
str $directive - Optional. One of recurring|singular|plural. Defaults to recurring.
str|bool - A Term Cycle ( i.e. Daily, Weekly, Monthly, Yearly, Lifetime, etc. ), else false on failure.
Add support here for fixed recurring payments configured through rrt="".
Time utilities.