Calendar package
No edit summary
No edit summary
Line 1: Line 1:
==== What is this? ====
Model that implements classes that makes aggregation (for statistics for example) easy.
Model that implements classes that makes 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.[[File:Calender model diagram.png|none|thumb|481x481px|link=https://wiki.mdriven.net/index.php/File:Calender_model_diagram.png]][[Special:Redirect/file/CalendarPackage.modlr|CalendarPackage.modlr]]
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.


There are a lot of methods that create a "web" of navigation between all entities in this model.
There are a lot of methods that create a "web" of navigation between all entities in this model.[[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]]


==== '''Notes on usage''' ====
* 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.
* Use the methods in Calendear to quickly find the Day for a given date when you link new or existing data to the structure.
* There is also a lot of helper function to find next/previous day, week or months or calculate time between them.
** For example in OCL: Day.GetDayForDate() 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.
==== '''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, you call FixupDatabase to create months and days of the calender.
Then with that, you call FixupCalendar to create months and days of the calender. You can call FixupCalendar many times without losing any data. It will simply update or correct problems.


Weeks is 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.
Weeks is 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.
Line 14: Line 24:


Use the country setting to define the default week definition for your users.
Use the country setting to define the default week definition for your users.
There is also a lot of helper function to find next/previous day, week or months or calculate time between them.
Integers called '''Ordinals''' are used to have a stable way to calculate how far apart objects are in time.
Use the methods in SysSingleton to quickly find the Day for a given date when you link new or existing data to the structure.

Revision as of 16:42, 27 February 2021

What is this?

Model that implements classes that makes 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.

There are a lot of methods that create a "web" of navigation between all entities in this model.

Calender model diagram.png

CalendarPackage.modlr

Notes on usage

  • 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.
  • Use the methods in Calendear to quickly find the Day for a given date when you link new or existing data to the structure.
  • There is also a lot of helper function to find next/previous day, week or months or calculate time between them.
    • For example in OCL: Day.GetDayForDate() 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.

Starting up

To create the data structure, start by using an action to create the years you want.

Then with that, you call FixupCalendar to create months and days of the calender. You can call FixupCalendar many times without losing any data. It will simply update or correct problems.

Weeks is 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 39 days ago on 03/26/2024. What links here