-------------------------------------------- Save this library as "Date_Lib.mv" in your Miva HTML directory and run it. The first code block below this MvCOMMENT is a function demonstration script. -------------------------------------------- http://localhost/Date_Lib.mv -------------------------------------------- Brian R. Bullock brian@wwwebweaver.com Function Junction http://wwwebweaver.com/func_junc/ The Miva Xbase3 Vending Machine http://wwwebweaver.com/db_vending/ Released to Public Domain Mar. 4, 1999 ============================================ Function Descriptions ============================================ [::_____tzone_____] Provides the time zone for the time_j, dyn_time_j, time_g and dyn_time_g. Default is the time zone for your Miva server. Change the MvFUNCRETURN VALUE if you wish to use another timezone (ie: MvFUNCRETURN VALUE="-8" for pacific standard time). ============================================ [::_____DOW_____] Returns the day of the week number for any valid date (Sunday=1, Monday=2, etc). Parameters: lf: Format ID of the date to be processed. t = time_t g = Gregorian date j = Julian days ld: The date to be processed. ============================================ [::_____T_Between_____] Time between dates. Output is a formatted string ##yr:##mo:##day:##hr:##min:##sec where ## are digits. Parameters: lf= Date Format Id (See DOW) lsd= Start date led= End date Both dates must be in 'lf' format. ============================================ [::_____Date_String_____] Convert a date to a human readable date/time string. Uses a "output key" to format the string. Parameters: lf= Date Format Id (See DOW) ld= Date to convert ltz= Time zone lkey= Output display key mdy: US date format dmy: European date format c: cookie date format n: name of day t: time of day z: name of time zone y: year m: name of month d: day of month You may input one or more of the characters above, in any order. If you you do not input at least one valid character then output will be in "cookie" format. If you input a 'c' then output will be in "cookie" format regardless of any other valid characters in the key. If any part of the key matches the pattern 'mdy' then the date portion of the output string will be in US standard format (ie: Mar 13, 1999). If any part of the key matches the pattern 'dmy' then the date portion of the output string will be in European standard format (ie: 13-Mar-1999). ============================================ [::_____time_j_____] Julian days equivalent to the system variable time_t. ============================================ [::_____dyn_time_j_____] Julian days equivalent to the system variable dyn_time_t. ============================================ [::_____time_g_____] Gregorian date equivalent to the system variable time_t. ============================================ [::_____dyn_time_g_____] Gregorian date equivalent to the system variable dyn_time_t. ============================================ [::_____Td2Gd_____] Time_t to Gregorian date. Parameters: ltd = Time_t date ltz = Time zone ============================================ [::_____Td2Jd_____] Time_t to Julian days. Parameters: ltd = Time_t date ltz = Time zone ============================================ [::_____Gd2Td_____] Gregorian date to Time_t. Parameters: lgd = Gregorian date Gregorian dates are formatted as "YYYYMMDDhhmmss" (year,month,day,hour,minute,second). YEAR, MONTH AND DAY ARE REQUIRED. Hour, minute and second are not required. All values must be left padded with zeros to fill their alloted space (ie: The first second of Jan 1, 1999 would be 19990101000001). The smallest valid date is the first second of Jan 1, 0000 (0000010100001) and the largest valid date is the last second of Dec 31, 9999 (99991231235959) ============================================ [::_____Gd2Jd_____] Gregorian date to Julian days. Parameters: lgd = Gregorian date ============================================ [::_____Jd2Td_____] Julian days to Time_t. Parameters: ljd = Julian Days date Julian days are formated as "day.fraction" and are the number of days and fractions of a day since 12 hours Universal Time (Greenwich mean noon) on January 1 of the year 4713 BC. ============================================ [::_____Jd2Gd_____] Julian days to Gregorian date. Parameters: ljd = Julian Days date ============================================
Date Conversion Demo:
Time_t Date   Gregorian date   Julian Days
 
Input a date format ID  
t=Time_t    g=Gregorian Date    j=Julian Days
Input a date  

Date_String Demo: &[gtime];
Input a date format ID  
t=Time_t    g=Gregorian Date    j=Julian Days
Input a date  
Input a time zone  
Input a display key  
c=cookie date format    n=name of day    t=time of day    z=name of time zone
d=day of month    m=name of month    y=year
One or more characters, any order (ie: nmdytz = Tuesday Mar 15, 1999 12:36:59 PST).

T_Between Demo: &[gstart];
Input a date format ID  
t=Time_t    g=Gregorian Date    j=Julian Days
Input a start date  
Input a end date  
_____Function_Library_____ _____tzone_____ Provides the time zone for the time_j, dyn_time_j, time_g and dyn_time_g. Default is the time zone for your Miva server. Change the MvFUNCRETURN VALUE below if you wish to use another timezone (ie: MvFUNCRETURN VALUE="-8" for pacific standard time). _____DOW_____ Returns the day of the week number for any valid date (Sunday=1, Monday=2, etc). Parameters lf: Format ID of the date to be processed. t = time_t (this duplicates the built-in time_t_dayofweek function) g = Gregorian date j = Julian days ld: The date to be processed _____T_Between_____ Parameters: lf= Date Format Id (See DOW) lsd= Start date led= End date Both dates must be in 'lf' format. _____Date_String_____ Parameters: lf= Date Format Id (See DOW) ld= Date ltz= Time zone lkey= Output display key mdy: US date format dmy: European date format c: cookie date format n: name of day t: time of day z: name of time zone y: year m: name of month d: day of month You may input one or more of the characters, in any order. If you you do not input a valid character then output will be in "cookie" format. If you input a 'c' then output will be in "cookie" format regardless of any other valid characters in the key. If any part of the key matches the pattern 'mdy' then the date portion of the output string will use a US standard format (ie: Mar 13, 1999). If any part of the key matches the pattern 'dmy' then the date portion of the output string will use a European standard format (ie: 13-Mar-1999). __Default__ Formatted as required for cookies _____time_j_____ Julian days equivalent to the system variable time_t. _____dyn_time_j_____ Julian days equivalent to the system variable dyn_time_t. _____time_g_____ Gregorian date equivalent to the system variable time_t. _____dyn_time_g_____ Gregorian date equivalent to the system variable dyn_time_t. _____Td2Jd_____ Time_t to Julian days. Parameters: ltd = Time_t date ltz = Time zone _____Td2Gd_____ Time_t to Gregorian date. Parameters: ltd = Time_t date ltz = Time zone _____Jd2Gd_____ Julian days to Gregorian date. Parameters: ljd = Julian Days date Julian days are formated as "day.fraction" and are the number of days and fractions of a day since 12 hours Universal Time (Greenwich mean noon) on January 1 of the year 4713 BC. _____Gd2Jd_____ Gregorian date to Julian days. Parameters: lgd = Gregorian date Gregorian dates are formatted as "YYYYMMDDhhmmss" (year,month,day,hour,minute,second). YEAR, MONTH AND DAY ARE REQUIRED. Hour, minute and second are not required. All values must be left padded with zeros to fill their alloted space (ie: The first second of Jan 1, 1999 would be 19990101000001). The smallest valid date is the first second of Jan 1, 0000 (0000010100001) and the largest valid date is the last second of Dec 31, 9999 (99991231235959) _____Gd2Td_____ Gregorian date to Time_t. Parameters: lgd = Gregorian date _____Jd2Td_____ Julian days to Time_t. Parameters: ljd = Julian Days date