Date Manipulation Made Easy with DateUtil.cls

Calculating the ISO week number manually? Not anymore.

 

Date logic in OpenEdge can feel like a labyrinth of edge cases, leap years, and formatting quirks. Whether you’re building reports, scheduling tasks, or validating timelines, even simple operations can spiral into complex code. 

That’s why in OE Essentials you will find DateUtil.cls: a utility class that makes date handling clean, consistent, and reliable. 

 

What DateUtil.cls Actually Handles

 

Here’s what it brings to your developer toolkit: 

📆 ISO Week Number Calculation: Need to know what week of the year a date falls in? DateUtil calculates ISO-compliant week numbers with a single method. 

📅 First and Last Day of Year or Month: Quickly retrieve the first day of any month or year—or the last day of the year—without manual math or formatting. 

📈 Month Length Lookup: Want to know how many days are in February 2024? DateUtil returns the correct count for any month/year combo. 

 

Why It Matters 

 

  • No more reinventing date logic: Replace dozens of lines of custom code with one reliable method call. 
  • Fewer bugs, cleaner logic: Built-in methods reduce the risk of off-by-one errors and leap year mishaps. 
  • Faster delivery: Spend less time debugging and more time building features your users care about. 

 

 

Use Cases That Shine

 

  • Generating calendar views or weekly summaries 
  • Validating date ranges for reports or exports 
  • Building time-based filters for queries 
  • Creating user-friendly date pickers or dashboards 

 

e.g.

 

class Tests.DateUtilUnitTest:  

     

    /*------------------------------------------------------------------------------ 

        Purpose: Test the GetISOWeekNumber method. 

    ------------------------------------------------------------------------------*/ 

    @Test. 

    method public void TestGetISOWeekNumber(): 

        define variable iResult as integer no-undo. 

         

        iResult = DateUtil:GetISOWeekNumber(date(10, 22, 2024)). 

        Assert:IsTrue(iResult = 43, "GetISOWeekNumber(10/22/2024) SHOULD RETURN 43"). 

         

    end method. 

end class. 

 

 

Final Thought

 

Date handling shouldn’t feel like a puzzle. With DateUtil.cls, it’s just another solved problem. Whether you’re building birthday reminders or fiscal year reports, this utility class keeps your timelines tidy and your logic lean. 

Got a date-related challenge you wish OE Essentials tackled? Submit an idea or issue on GitHub—we’re building this toolkit with you. 

 


 

Author: Ioana Trasca, Office Manager & Communications Officer

People-oriented person passionate about writing, reading, traveling and a forever animal lover.

SEE HOW WE WORK.

FOLLOW US