Source Code Documentation


Field Summary | Method Summary | Field Detail | Method Detail

Package s2Member\Utilities

s2member\includes\classes\utils-time.inc.php at line #28

Class c_ws_plugin__s2member_utils_time

c_ws_plugin__s2member_utils_time

public class c_ws_plugin__s2member_utils_time

Time utilities.

Since:

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 user_id, period1, period3, last_payment_time, or an optional eotper.

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 [D,W,M,Y,L,Day,Week,Month,Year,Lifetime] into Daily, Weekly, Monthly, Yearly, Lifetime.

( 5 Methods )
Method Detail

s2member\includes\classes\utils-time.inc.php at line #312

amount_period_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.

Since:

3.5

Parameters:

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.

Returns:

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. ).

Todo:

Add support here for fixed recurring payments configured through rrt="".

[ back to top ]

s2member\includes\classes\utils-time.inc.php at line #44

approx_time_difference()

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.

Since:

3.5

Parameters:

int $from - Beginning timestamp to start from.

int $to - Ending timestamp to stop at.

Returns:

str - Human readable difference between $from and $to.

[ back to top ]

s2member\includes\classes\utils-time.inc.php at line #125

auto_eot_time()

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).

Since:

3.5

Parameters:

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".

Returns:

int - Unix timestamp indicating the EOT Time calculated by this routine.

[ back to top ]

s2member\includes\classes\utils-time.inc.php at line #271

period_term()

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.

Since:

3.5

Parameters:

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.

Returns:

str - Verbose (lowercase) Period Term description ( i.e. weekly, every 3 weeks, lifetime, 3 months, 1 month, etc. ).

Todo:

Add support here for fixed recurring payments configured through rrt="".

[ back to top ]

s2member\includes\classes\utils-time.inc.php at line #227

term_cycle()

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.

Since:

3.5

Parameters:

str $term_or_period_term - A Term, or a "Period Term" combination.

str $directive - Optional. One of recurring|singular|plural. Defaults to recurring.

Returns:

str|bool - A Term Cycle ( i.e. Daily, Weekly, Monthly, Yearly, Lifetime, etc. ), else false on failure.

Todo:

Add support here for fixed recurring payments configured through rrt="".

[ back to top ]

Source Code Documentation


Field Summary | Method Summary | Field Detail | Method Detail