Skip to content

Conversation

Copy link

Copilot AI commented Sep 17, 2025

This PR implements a comprehensive calendar sub function for AS400 COBOL that determines the day of the week for any given date and identifies recognized holidays. The solution addresses the need for calendar functionality in COBOL applications with a robust, reusable subroutine.

What's New

Core Calendar Subroutine (CALENDAR.CBLLE)

A callable COBOL subroutine that provides:

  • Day of week calculation for any date between years 1600-3000
  • Holiday detection for Canada Day (July 1st), New Year's Day (January 1st), and Christmas Day (December 25th)
  • Comprehensive input validation with clear error messages
  • Linkage section interface for integration with existing COBOL applications

The subroutine uses COBOL intrinsic functions (INTEGER-OF-DATE, MOD) for accurate date calculations following standard calendar algorithms.

Interactive Calendar Application (CALAPPS.CBLLE)

A menu-driven application that demonstrates the subroutine's capabilities:

================================================
                 MAIN MENU
================================================
1. Check specific date
2. Check current date  
3. Check Canada Day for a year
4. List upcoming holidays
Q. Quit

Comprehensive Test Suite (TESTCAL.CBLLE)

Automated and interactive testing that validates:

  • Known date/day combinations (e.g., Canada Day 2025 = Tuesday)
  • Holiday detection accuracy
  • Input validation and error handling
  • Edge cases and boundary conditions

Usage Example

CALL "CALENDAR" USING WS-INPUT-DATE, WS-OUTPUT-DATA.

IF WS-ERROR-FLAG = 'N' THEN
    DISPLAY "Day: " WS-DAY-NAME
    IF WS-IS-HOLIDAY = 'Y' THEN
        DISPLAY "Holiday: " WS-HOLIDAY-NAME
    END-IF
ELSE
    DISPLAY "Error: " WS-ERROR-MESSAGE
END-IF.

Technical Details

The implementation follows AS400 COBOL standards with:

  • Proper .CBLLE file format in the QCBLLESRC directory
  • Consistent syntax with existing repository patterns
  • Self-contained design with no external dependencies
  • Modular structure for easy maintenance and extension

The calendar subroutine can be easily extended to support additional holidays or enhanced date functionality as needed by applications.

Files Added

  • AS400/QCBLLESRC/CALENDAR.CBLLE - Core calendar subroutine
  • AS400/QCBLLESRC/CALAPPS.CBLLE - Interactive calendar application
  • AS400/QCBLLESRC/TESTCAL.CBLLE - Comprehensive test suite
  • AS400/QCBLLESRC/EXAMPLE.CBLLE - Simple usage demonstration
  • docs/CALENDAR-SUBROUTINE-README.md - Complete documentation and API reference

This calendar subroutine provides essential date functionality for COBOL applications and serves as a foundation for more advanced calendar features.

Fixes #3


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 17, 2025 20:27
Co-authored-by: raykao <860691+raykao@users.noreply.github.com>
Co-authored-by: raykao <860691+raykao@users.noreply.github.com>
Copilot AI changed the title [WIP] Need to create a new calendar sub function for cobol to determine the current day of the week Implement calendar subroutine for day-of-week and holiday detection in AS400 COBOL Sep 17, 2025
Copilot AI requested a review from raykao September 17, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need to create a new calendar sub function for cobol to determine the current day of the week

2 participants