Skip to content

Use a Struct or Structs for the holiday definition map #2

@CoderDennis

Description

@CoderDennis

As it stands, the map defining each holiday doesn't have any constraints on what fields it contains.

I think this will be done with structs, but I haven't worked with them much yet.

There are 3 different kinds of holiday definitions. Does that mean 3 different Struct types?

  1. static holidays fall on a given day and month every year. eg. New Year's Day is always January 1st.
  2. nth holidays fall on the nth weekday of a given month. eg. Memorial Day in the US is on the last Monday in May.
  3. function holidays use a function to determine their date. The function typically has year as its parameter. The definition of a function is given as a tuple {ModuleName, :functionName, [params]}. Easter Sunday is the best example. There can also be a 4th element of the tuple, which is an integer representing how many days to add (or subtract via negative number) to the date returned by the function. For Good Friday we use the :easter function and subtract 2 days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions