Skip to content

Resolve the year and leap-year flag from a Julian string

Resolve a 4-digit calendar year and leap-year flag from a Julian string, triggered when called by OP-007 step 3, or directly by callers.

Field Value
Operation ID OP-008
Trigger Called by OP-007 step 3, or directly by callers
Inputs julian, millenium
Outputs int year, out bool isLeapYear
Primary components Julian.GetYear(string julian, out bool isLeapYear, int millenium = 0)
Entry point Common/SAIF.Common/Classes/Julian.cs

Steps

  1. If millenium < 1000, derive it from the current system year: take the first digit of DateTime.Now.Year and multiply by 1000 (yields 2000 for any year 2000-2999). (BR-024)
  2. If the Julian string is longer than 3 characters, parse everything before the final three characters as the year component; otherwise default the year to the millennium.
  3. If the resulting year is below 1000 (a 1- or 2-digit year was supplied), add the millennium to it. (BR-024)
  4. Instantiate System.Globalization.JulianCalendar and set isLeapYear from calendar.IsLeapYear(year). (BR-025)
  5. Return the resolved year.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["GetYear(julian, out isLeapYear,<br>millenium) called"]) --> M{"millenium < 1000?"}
    M -->|Yes| DeriveM["Derive millennium from current<br>year's first digit x 1000"]
    M -->|No| LenCheck
    DeriveM --> LenCheck{"Julian string longer<br>than 3 characters?"}
    LenCheck -->|Yes| ParseYear["Parse chars before final<br>three as year component"]
    LenCheck -->|No| DefaultYear["Default year to millennium"]
    ParseYear --> YearCheck
    DefaultYear --> YearCheck{"Resulting year < 1000?"}
    YearCheck -->|Yes| AddM["Add millennium to year"]
    YearCheck -->|No| Calendar
    AddM --> Calendar["Instantiate JulianCalendar;<br>set isLeapYear"]
    Calendar --> End(["Return resolved year"])

Sources

  • Common/SAIF.Common/Classes/Julian.cs