$PBExportHeader$eaf_n_cst_datetimeservice.sru forward global type eaf_n_cst_datetimeservice from n_cst_baseservice end type end forward global type eaf_n_cst_datetimeservice from n_cst_baseservice long il_languageid = 0 string is_crlf = "" end type global eaf_n_cst_datetimeservice eaf_n_cst_datetimeservice type variables end variables forward prototypes public function long separatedate (date ad_date, ref long al_returnyear, ref long al_returnmonth, ref long al_returnday) public function date relativemonth (date ad_date, long al_monthaddition) public function date relativeyear (date ad_date, long al_yearaddition) public function boolean isleapyear (date ad_date) public function boolean isleapyear (long al_year) public function boolean isweekday (date ad_date) public function boolean isweekend (date ad_date) public function string dayname (long al_daynumber) public function string daynamefirstofmonth (date ad_date) public function string daynamefirstofmonth (date ad_date, long al_languageid) public function string monthname (date ad_date) public function string monthname (long al_monthnumber) public function string monthname (date ad_date, long al_languageid) public function string dayname (date ad_date) public function string daynamelastofmonth (date ad_date, long al_languageid) public function string daynamelastofmonth (date ad_date) public function string dayname (date ad_date, long al_languageid) public function string dayname (long al_daynumber, long al_languageid) public function string monthname (long al_monthnumber, long al_languageid) public function long daycount (date ad_monthdate) public function string transdatetimeformat (string dtdata) public function long getmonthdate (long year, long month, ref datetime monthfirstday, ref datetime monthlastday) end prototypes public function long separatedate (date ad_date, ref long al_returnyear, ref long al_returnmonth, ref long al_returnday);//////////////////////////////////////////////////////////////// // Description: // Separates a Date field into Year, Month, and Day fields // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date // al_returnyear - Place holder for the Year portion of the date // al_returnmonth - Place holder for the Month portion of the date // al_returnday - Place holder for the Day portion of the date // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "separateDate " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date, ref al_returnyear, " + & "ref al_returnmonth, ref al_returnday)~r~n" + & "ad_date="+string(ad_date)) End If // Declare local variables long ll_year long ll_month long ll_day // Perform cleanup al_returnyear = 0 al_returnmonth = 0 al_returnday = 0 // Validate arguments If IsNull(ad_date) Then addError(METHOD_NAME, "Invalid ad_date argument") Return -1 End If // Break out the Date ll_year = long(string(ad_date,'yyyy')) ll_month = month(ad_date) ll_day = day(ad_date) // Validate the break values If isNull(ll_year) Or isNull(ll_month) Or isNull(ll_day) Then addError(METHOD_NAME, "Invalid ad_date argument (broken out null)") Return -1 End If If ll_year< 1 Or ll_month< 1 Or ll_day< 1 Then addError(METHOD_NAME, "Invalid ad_date argument (broken out)") Return -1 End If // Success al_returnyear = ll_year al_returnmonth = ll_month al_returnday = ll_day Return 1 end function public function date relativemonth (date ad_date, long al_monthaddition);//////////////////////////////////////////////////////////////// // Description: // Determines a relative Date based on a starting date and // a number of months to add or subtract to it // Revisions // 1.0 - Initial version // Arguments: // ad_date - The starting date // al_monthaddition - The number of months to add or subtract to // the starting date // Returns: // The Relative month // Null - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "relativeMonth " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date, al_monthaddition) " + & "ad_date="+string(ad_date) + " al_monthaddition="+string(al_monthaddition)) End If // Declare local variables constant long MONTHS_PER_YEAR = 12 long ll_originalyear long ll_originalmonth long ll_originalday long ll_possibletargetyear long ll_possibletargetmonth long ll_possibletargetday long ll_daycount long ll_finaltargetmonth long ll_finaltargetyear long ll_finaltargetday date ldt_finaltarget date ldt_null // Initialize setNull(ldt_null) // Validate arguments If IsNull(ad_date) Then addError(METHOD_NAME, "Invalid ad_date argument") Return ldt_null End If If IsNull(al_monthaddition) Then addError(METHOD_NAME, "Invalid al_monthaddition argument") Return ldt_null End If // Break out the original Date If separateDate(ad_date, ll_originalyear, ll_originalmonth, ll_originalday) <= 0 Then addError(METHOD_NAME, "Invalid separateDate() operation") Return ldt_null End If // If life was simple, come up with the possible tCaJrQget values ll_possibletargetyear = ll_originalyear + (al_monthaddition / MONTHS_PER_YEAR) ll_possibletargetmonth = ll_originalmonth + mod(al_monthaddition, MONTHS_PER_YEAR) ll_possibletargetday = ll_originalday // -- Check for a valid month If ll_possibletargetmonth > MONTHS_PER_YEAR Then // Not valid, added over to a new year. Make the corrections ll_finaltargetmonth = ll_possibletargetmonth - MONTHS_PER_YEAR ll_finaltargetyear = ll_possibletargetyear + 1 ElseIf ll_possibletargetmonth <= 0 Then // Not valid, subtracted to the previous year. Make the corrections ll_finaltargetmonth = ll_possibletargetmonth + MONTHS_PER_YEAR ll_finaltargetyear = ll_possibletargetyear - 1 Else // Yes, it is valid ll_finaltargetmonth = ll_possibletargetmonth ll_finaltargetyear = ll_possibletargetyear End If // -- Check for a valid date // Get the number of days on the Target Month ll_daycount = dayCount( date(ll_finaltargetyear, ll_finaltargetmonth, 1)) // Enforce that the day cannot be greter than the dayCount If ll_finaltargetday > ll_daycount Then ll_finaltargetday = ll_daycount End IF // Convert into a date ldt_finaltarget = date(ll_finaltargetyear, ll_finaltargetmonth, ll_finaltargetday) Return ldt_finaltarget end function public function date relativeyear (date ad_date, long al_yearaddition);//////////////////////////////////////////////////////////////// // Description: // Determines a relative Year based on a starting date and // a number of Years to add or subtract to it // Revisions // 1.0 - Initial version // Arguments: // ad_date - The starting date // al_yearaddition - The number of Years to add or subtract to // the starting date // Returns: // The Relative Year // Null - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "relativeYear " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date, al_yearaddition) " + & "ad_date="+string(ad_date) + " al_yearaddition="+string(al_yearaddition)) End If // Declare local variables long ll_originalyear long ll_originalmonth long ll_originalday long ll_daycount long ll_finaltargetmonth long ll_finaltargetyear long ll_finaltargetday date ldt_finaltarget date ldt_null // Initialize setNull(ldt_null) // Validate arguments If IsNull(ad_date) Then addError(METHOD_NAME, "Invalid ad_date argument") Return ldt_null End If If IsNull(al_yearaddition) Then addError(METHOD_NAME, "Invalid al_yearaddition argument") Return ldt_null End If // Break out the original Date If separateDate(ad_date, ll_originalyear, ll_originalmonth, ll_originalday) <= 0 Then addError(METHOD_NAME, "Invalid separateDate() operation") Return ldt_null End If // Set up the possible date ll_finaltargetyear = ll_originalyear + al_yearaddition ll_finaltargetmonth = ll_originalmonth ll_finaltargetday = ll_originalday // -- Check for a valid date // Get the number of days on the Target Month ll_daycount = dayCount( date(ll_finaltargetyear, ll_finaltargetmonth, 1)) // Enforce that the day cannot be greter than the dayCount If ll_finaltargetday > ll_daycount Then ll_finaltargetday = ll_daycount End IF // Convert into a date ldt_finaltarget = date(ll_finaltargetyear, ll_finaltargetmonth, ll_finaltargetday) Return ldt_finaltarget end function public function boolean isleapyear (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Determines the Date passed in is a Leap Year // Revisions // 1.0 - Initial version // Arguments: // ad_date - Date to be tested // Returns: // True - If it is a leap year // False - If it is not a leap year // Null - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "isLeapYear " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date) " + & "ad_date="+string(ad_date)) End If // Function overload Return isLeapYear (long(string(ad_date,'yyyy'))) end function public function boolean isleapyear (long al_year);//////////////////////////////////////////////////////////////// // Description: // Determines the Date Year in is a Leap Year // Revisions // 1.0 - Initial version // Arguments: // al_year - Year to be tested // Returns: // True - If it is a leap year // False - If it is not a leap year // Null - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "isLeapYear " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(al_year) " + & "al_year="+string(al_year)) End If // Declare local variables boolean lb_null // Validate arguments If IsNull(al_year) Or al_year < 0 Then addError(METHOD_NAME, "Invalid al_year argument") setNull(lb_null) Return lb_null End If // Mathematical calculation to determine leap year If ((mod(al_year, 4) = 0 And mod(al_year, 100) <> 0) Or & (mod(al_year, 400) = 0)) Then // Yes, it is a leap year Return true End If // Not a leap year Return false end function public function boolean isweekday (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Determines the Date passed in is a Week Day (Monday - Friday) // Revisions // 1.0 - Initial version // Arguments: // ad_date - Date to be tested // Returns: // True - If it is a Week Day // False - If it is not Week Day //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "isWeekDay " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date) " + & "ad_date="+string(ad_date)) End If // Validate arguments If IsNull(ad_date) Then addError(METHOD_NAME, "Invalid ad_date argument") Return false End If // Check for a Monday thru Friday If (dayNumber(ad_date) >= 2) And (dayNumber(ad_date) <= 6) Then // Yes, it is a Week Day Return true End If // No, it is Not a Week Day Return false end function public function boolean isweekend (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Determines the Date passed in is a WeekEnd (Sunday or Saturday) // Revisions // 1.0 - Initial version // Arguments: // ad_date - Date to be tested // Returns: // True - If it is a WeekEnd // False - If it is not WeekEnd //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "isWeekEnd " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date) " + & "ad_date="+string(ad_date)) End If // Validate arguments If IsNull(ad_date) Then addError(METHOD_NAME, "Invalid ad_date argument") Return false End If // Check for a Sunday or Saturday If (dayNumber(ad_date) = 1) Or (dayNumber(ad_date) = 2) Then // Yes, it is a WeekEnd Return true End If // No, it is Not a WeekEnd Return false end function public function string dayname (long al_daynumber);//////////////////////////////////////////////////////////////// // Description: // Determines the Day Name for the passed in Day Number for // the default Language // Revisions // 1.0 - Initial version // Arguments: // al_daynumber - Day Number for which to determine the Day Name // Returns: // The Day Name // "?" + English Day Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayName " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(al_daynumber) " + & "al_daynumber="+string(al_daynumber)) End If // Function overload default language Return dayName (al_daynumber, il_languageid) end function public function string daynamefirstofmonth (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Returns Day One of the passed in month in the default // language // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date containing the month // Returns: // The first day of the month: "Sunday", "Monday", ... // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayNameFirstOfMonth " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date) ad_date="+string(ad_date)) End If // Function overload Return dayNameFirstOfMonth(ad_date, il_languageid) end function public function string daynamefirstofmonth (date ad_date, long al_languageid);//////////////////////////////////////////////////////////////// // Description: // Returns Day One of the passed in month in the passed in // language // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date containing the month // al_languageid - The desired language // Returns: // The first day of the month: "Sunday", "Monday", ... // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayNameFirstOfMonth " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date, al_languageid) "+ & "ad_date="+string(ad_date)+"al_languageid="+string(al_languageid)) End If Return dayName(date (long(string(ad_date,'yyyy')), month(ad_date), 1), al_languageid) end function public function string monthname (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Determines the Month Name for the passed in Month Date // for the service default language // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date which to determine the Month Name // Returns: // The Month Name // "?" + English Month Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "monthName " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date) " + & "ad_date="+string(ad_date)) End If // Function overload default language Return monthName (month(ad_date), il_languageid) end function public function string monthname (long al_monthnumber);//////////////////////////////////////////////////////////////// // Description: // Determines the Month Name for the passed in Month Number // for the service default language // Revisions // 1.0 - Initial version // Arguments: // al_monthnumber - Month Number for which to determine the // Month Name // Returns: // The Month Name // "?" + English Month Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "monthName " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(al_monthnumber) " + & "al_monthnumber="+string(al_monthnumber)) End If // Function overload default language Return monthName (al_monthnumber, il_languageid) end function public function string monthname (date ad_date, long al_languageid);//////////////////////////////////////////////////////////////// // Description: // Determines the Month Name for the passed in Month Date // for the passed in language // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date which to determine the Month Name // al_languageid - The desired language // Returns: // The Month Name // "?" + English Month Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "monthName " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date, al_languageid) " + & "ad_date="+string(ad_date)+" al_languageid="+string(al_languageid)) End If Return monthName (month(ad_date), al_languageid) end function public function string dayname (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Determines the Day Name for the passed in Date // Revisions // 1.0 - Initial version // Arguments: // ad_date - Date for which to determine the Day Name // Returns: // The Day Name // "?" + English Day Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayName " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date) " + & "ad_date="+string(ad_date)) End If // Function overload default language Return DayName (dayNumber(ad_date), il_languageid) end function public function string daynamelastofmonth (date ad_date, long al_languageid);//////////////////////////////////////////////////////////////// // Description: // Returns Last Day of the passed in month in the passed in // language // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date containing the month // al_languageid - The desired language // Returns: // The last day of the month: "Sunday", "Monday", ... // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayNameLastOfMonth " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_date, al_languageid) "+ & "ad_date="+string(ad_date)+" al_languageid="+string(al_languageid)) End If // Validate arguments If isNull(ad_date) Then addError (METHOD_NAME, "Invalid ad_date argument") Return "!" End If Return dayName(date (long(string(ad_date,'yyyy')), & month(ad_date), & dayCount(ad_date)), & al_languageid) end function public function string daynamelastofmonth (date ad_date);//////////////////////////////////////////////////////////////// // Description: // Returns Last Day of the passed in month in the passed in // the default language // Revisions // 1.0 - Initial version // Arguments: // ad_date - The date containing the month // Returns: // The last day of the month: "Sunday", "Monday", ... // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayNameLastOfMonth " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date) ad_date="+string(ad_date)) End If // Function overload Return dayNameLastOfMonth(ad_date, il_languageid) end function public function string dayname (date ad_date, long al_languageid);//////////////////////////////////////////////////////////////// // Description: // Determines the Day Name for the passed in Date // Revisions // 1.0 - Initial version // Arguments: // ad_date - Date for which to determine the Day Name // al_languageid - The desired language // Returns: // The Day Name // "?" + English Day Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayName " If ib_trace And ib_detailed Then inv_log.traceLog (METHOD_NAME, "(ad_date, al_languageid) " + & "ad_date="+string(ad_date)+" al_languageid="+string(al_languageid)) End If Return DayName (dayNumber(ad_date), al_languageid) end function public function string dayname (long al_daynumber, long al_languageid);//////////////////////////////////////////////////////////////// // Description: // Determines the Day Name for the passed in Day Number // // This method should be extended in order to support other // languages // Revisions // 1.0 - Initial version // Arguments: // al_daynumber - Day Number for which to determine the Day Name // al_languageid - The desired language // Returns: // The Day Name // "?" + English Day Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayName " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(al_daynumber, al_languageid) " + & "al_daynumber="+string(al_daynumber)+" al_languageid="+string(al_languageid)) End If // Declare local variables string ls_dayname string ls_english[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", & "Thursday", "Friday", "Saturday"} string ls_spanish[7] = {"Domingo", "Lunes", "Martes", "Miercoles", & "Jueves", "Viernes", "Sabado"} // Validate arguments If IsNull(al_daynumber) or al_daynumber <1 or al_daynumber >7 Then addError(METHOD_NAME, "Invalid al_daynumber argument") Return '!' End If If IsNull(al_languageid) Then addError(METHOD_NAME, "Invalid al_languageid argument") Return '!' End If Choose Case al_languageid Case 1 // English ls_dayname = ls_english[al_daynumber] Case 2 // Spanish ls_dayname = ls_spanish[al_daynumber] Case Else ls_dayname = "?" + ls_english[al_daynumber] + "?" addError(METHOD_NAME, "Unsuported languageID. " + & "Code support on descendant of this method") End Choose Return ls_dayname end function public function string monthname (long al_monthnumber, long al_languageid);//////////////////////////////////////////////////////////////// // Description: // Determines the Month Name for the passed in Month Number // // This method should be extended in order to support other // languages // Revisions // 1.0 - Initial version // Arguments: // al_monthnumber - Month Number for which to determine the // Month Name // al_languageid - The desired language // Returns: // The Month Name // "?" + English Month Name + "?" - Failure due to Unsupported Language // In this case, simply code descendant to add support // "!" - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "monthName " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(al_monthnumber, al_languageid) " + & "al_monthnumber="+string(al_monthnumber)+" al_languageid="+string(al_languageid)) End If // Declare local variables string ls_monthname string ls_english[12] = {"January", "February", "March", "April", "May", "June", & "July", "August", "September", "October", "November", "December"} string ls_spanish[12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", & "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"} // Validate arguments If IsNull(al_monthnumber) or al_monthnumber <1 or al_monthnumber >12 Then addError(METHOD_NAME, "Invalid al_monthnumber argument") Return '!' End If If IsNull(al_languageid) Then addError(METHOD_NAME, "Invalid al_languageid argument") Return '!' End If Choose Case al_languageid Case 1 // Enlish ls_monthname = ls_english[al_monthnumber] Case 2 // Spanish ls_monthname = ls_spanish[al_monthnumber] Case Else ls_monthname = "?" + ls_english[al_monthnumber] + "?" addError(METHOD_NAME, "Unsuported languageID. " + & "Code support on descendant of this method") End Choose Return ls_monthname end function public function long daycount (date ad_monthdate);//////////////////////////////////////////////////////////////// // Description: // Returns number of days for the passed in month // Revisions // 1.0 - Initial version // Arguments: // ad_monthdate - The date containing the month // Returns: // >0 - The number of days for the month // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Inc. All rights reserved. // Any distribution of the Youngsoft Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "dayCount " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(ad_monthdate) ad_monthdate="+string(ad_monthdate)) End If // Declare local variables long ll_month long ll_days // Validate arguments If IsNull(ad_monthdate) Then addError(METHOD_NAME, "Invalid ad_monthdate argument") Return -1 End If // Get the month ll_month = month(ad_monthdate) If IsNull(ll_month) Or ll_month < 0 Or ll_month > 12 Then addError(METHOD_NAME, "Invalid ad_monthdate argument (month check)") Return -1 End If Choose Case ll_month Case 1 ll_days = 31 Case 2 If isLeapYear(ad_monthdate) Then ll_days = 29 Else ll_days = 28 End If Case 3 ll_days = 31 Case 4 ll_days = 30 Case 5 ll_days = 31 Case 6 ll_days = 30 Case 7 ll_days = 31 Case 8 ll_days = 31 Case 9 ll_days = 30 Case 10 ll_days = 31 Case 11 ll_days = 30 Case 12 ll_days = 31 End Choose Return ll_days end function public function string transdatetimeformat (string dtdata);constant string METHOD_NAME = "TransDateTimeFormat " integer li_p, li_n string ls_str, ls_ch, ls_dbms ls_dbms = Upper(Left(sqlca.dbms, 3)) if ls_dbms = "" then addError (METHOD_NAME, "Invalid SQLCA.dbms value, it is empty") return dtdata end if ls_str = "" choose case ls_dbms case "INF" // informix for li_p = 1 to Len(dtdata) ls_ch = Mid(dtdata, li_p, 1) if ls_ch = "/" then ls_str += "-" else ls_str += ls_ch end if next return "'" + ls_str + "'" case "O10", "O90", "O84" if Len(trim(dtdata)) > 12 then ls_str = "to_date('" + dtdata + "','yyyy/mm/dd hh24:mi:ss')" else ls_str = "to_date('" + dtdata + "','yyyy/mm/dd')" end if return ls_str case "DB2" for li_p = 1 to Len(dtdata) ls_ch = Mid(dtdata, li_p, 1) if ls_ch = "/" then ls_str += "-" else ls_str += ls_ch end if next ls_str = "timestamp_iso('" + ls_str + "')" return ls_str case else return "'" + String(dtdata) + "'" end choose end function public function long getmonthdate (long year, long month, ref datetime monthfirstday, ref datetime monthlastday);//////////////////////////////////////////////////////////////// // Description: // Get the begin day and end day of the month // Revisions // 1.0 - Initial version // Arguments: // year: year // mon: month // monthfirstday: the first day of the month returned // monthlastday: the end day of the month returned // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft, Inc. All rights reserved. // Any distribution of the Youngsoft, Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft, Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "GetMonthDate " Date ld_nextmonthfirstday if year < 0 or year >= 9999 then addError (METHOD_NAME, "Invalid year argument, " + String(year)) return -1 end if if month < 1 or month > 12 then addError (METHOD_NAME, "Invalid month argument, " + String(month)) return -1 end if monthfirstday = DateTime(Date(year, month, 1)) if month = 12 then ld_nextmonthfirstday = Date(year + 1, 1, 1) else ld_nextmonthfirstday = Date(year, month + 1, 1) end if monthlastday = DateTime(RelativeDate(ld_nextmonthfirstday, -1)) return 1 end function on eaf_n_cst_datetimeservice.create call super::create end on on eaf_n_cst_datetimeservice.destroy call super::destroy end on
- Sources
- EAF.NET
- eaf_shared
- eaf_n_cst_datetimeservice.sru
File: eaf_n_cst_datetimeservice.sru
Size: 34897
Date: Tue, 22 Jan 2008 23:39:25 +0100
Size: 34897
Date: Tue, 22 Jan 2008 23:39:25 +0100
- n_cst_baseservice eaf_n_cst_datetimeservice(sru)
- daycount (date ad_monthdate) returns long
- dayname (date ad_date) returns string
- dayname (date ad_date, long al_languageid) returns string
- dayname (long al_daynumber) returns string
- dayname (long al_daynumber, long al_languageid) returns string
- daynamefirstofmonth (date ad_date) returns string
- daynamefirstofmonth (date ad_date, long al_languageid) returns string
- daynamelastofmonth (date ad_date) returns string
- daynamelastofmonth (date ad_date, long al_languageid) returns string
- getmonthdate (long year, long month, ref datetime monthfirstday, ref datetime monthlastday) returns long
- isleapyear (date ad_date) returns boolean
- isleapyear (long al_year) returns boolean
- isweekday (date ad_date) returns boolean
- isweekend (date ad_date) returns boolean
- monthname (date ad_date) returns string
- monthname (date ad_date, long al_languageid) returns string
- monthname (long al_monthnumber) returns string
- monthname (long al_monthnumber, long al_languageid) returns string
- relativemonth (date ad_date, long al_monthaddition) returns date
- relativeyear (date ad_date, long al_yearaddition) returns date
- separatedate (date ad_date, ref long al_returnyear, ref long al_returnmonth, ref long al_returnday) returns long
- transdatetimeformat (string dtdata) returns string