Calendar package
No edit summary
No edit summary
Line 1: Line 1:
==== What is This? ====
==== What is This? ====
This is a model that implements classes, making aggregation (for statistics for example) easy.
This is a model that implements classes, making aggregation (for statistics, for example) easy.


It follows a common pattern with dimensions from data analysis. By prepopulating the database with days, months, years, weeks, etc, you can easily (and efficiently) find data to present in a diagram or table.
It follows a common pattern with dimensions from data analysis. By prepopulating the database with days, months, years, weeks, etc, you can easily (and efficiently) find data to present in a diagram or table.


This model is cross-linked between all entities making "conversion" between different calendar objects easy.
This model is cross-linked between all entities making the "conversion" between different calendar objects easy.


This package also contains views for creating, viewing, and maintaining the model content.[[File:Calender model diagram.png|none|thumb|776x776px|link=https://wiki.mdriven.net/index.php/File:Calender_model_diagram.png]][[Special:Redirect/file/CalendarPackage.modlr|CalendarPackage.modlr]]
This package also contains views for creating, viewing, and maintaining the model content.[[File:Calender model diagram.png|none|thumb|776x776px|link=https://wiki.mdriven.net/index.php/File:Calender_model_diagram.png]]Download it here: [[Special:Redirect/file/CalendarPackage.modlr|CalendarPackage.modlr]]


==== '''Notes on Usage''' ====
==== '''Notes on Usage''' ====
* The Calendar "main class" is a Singleton. Use Calendar.SO as a short way to access the singleton object.
# The Calendar "main class" is a Singleton. Use Calendar.SO as a short way to access the singleton object.
** For example in OCL: '''Calendar.SO.Today''' will return a Day object for today.
#* For example in OCL: <code>Calendar.SO.Today</code> will return a Day object for today.
* Use the methods in Calendar to quickly find the Day for a given date when you link new or existing data to the structure.
# Use the methods in Calendar to quickly find the Day for a given date when you link new or existing data to the structure.
* There are also several helper functions to find the next/previous day, week, or month or calculate the time between them.
# There are also several helper functions to find the next/previous day, week, or month or calculate the time between them.
** For example in OCL: Day.GetDayForDate() returns a Day object by building a dictionary first for quick lookups.
#* For example in OCL: <code>Day.GetDayForDate()</code> returns a Day object by building a dictionary first for quick lookups.
* Integers called '''Ordinals''' are used to have a stable way to calculate how far apart objects are in time.
# Integers called '''Ordinals''' are used to have a stable way to calculate how far apart objects are in time.


==== '''Starting Up''' ====
==== '''Starting Up''' ====
To create the data structure, start by using an action to create the years you want.
* To create the data structure, start by using an action to create the years you want.
 
* Then with that, call FixupCalendar to create months and days of the calendar. You can call FixupCalendar many times without losing any data. It will simply update or correct problems.
Then with that, call FixupCalendar to create months and days of the calendar. You can call FixupCalendar many times without losing any data. It will simply update or correct problems.
* Weeks are a bit special. Week definitions vary in different parts of the world. Therefore, the WeekDefinition class sets the first day of the week, and weeks are then generated based on that.
 
* You can also define Saturday and Sunday (for example) as the "days off" every week.
Weeks are a bit special. Week definitions vary in different parts of the world. Therefore, the WeekDefinition class sets the first day of the week, and weeks are then generated based on that.
* Use the country setting to define the default week definition for your users.
 
You can also define Saturday and Sunday (for example) as the "days off" every week.
 
Use the country setting to define the default week definition for your users.
[[Category:Packages]]
[[Category:Packages]]

Revision as of 05:43, 16 June 2023

What is This?

This is a model that implements classes, making aggregation (for statistics, for example) easy.

It follows a common pattern with dimensions from data analysis. By prepopulating the database with days, months, years, weeks, etc, you can easily (and efficiently) find data to present in a diagram or table.

This model is cross-linked between all entities making the "conversion" between different calendar objects easy.

This package also contains views for creating, viewing, and maintaining the model content.

Calender model diagram.png

Download it here: CalendarPackage.modlr

Notes on Usage

  1. The Calendar "main class" is a Singleton. Use Calendar.SO as a short way to access the singleton object.
    • For example in OCL: Calendar.SO.Today will return a Day object for today.
  2. Use the methods in Calendar to quickly find the Day for a given date when you link new or existing data to the structure.
  3. There are also several helper functions to find the next/previous day, week, or month or calculate the time between them.
    • For example in OCL: Day.GetDayForDate() returns a Day object by building a dictionary first for quick lookups.
  4. Integers called Ordinals are used to have a stable way to calculate how far apart objects are in time.

Starting Up

  • To create the data structure, start by using an action to create the years you want.
  • Then with that, call FixupCalendar to create months and days of the calendar. You can call FixupCalendar many times without losing any data. It will simply update or correct problems.
  • Weeks are a bit special. Week definitions vary in different parts of the world. Therefore, the WeekDefinition class sets the first day of the week, and weeks are then generated based on that.
  • You can also define Saturday and Sunday (for example) as the "days off" every week.
  • Use the country setting to define the default week definition for your users.
This page was edited 46 days ago on 03/26/2024. What links here