Git Product home page Git Product logo

htmlcalendar's Introduction

HtmlCalendar

File Structure

This project is a Gregorian calendar generator for a given year that generates static html files for the years that are passed into the command-line of the program. For each year that is passed into the command-line it generates a .html file that contains the calendar for that year the years before and after it.

The gnenerated .html file has the following format:

Walkthrough

The following Video provides a quick walkthrough of the code.

Building the Project

Premake5 is used to build the project for visual_Studio-2019. To build the project binaries:

  • Run the GenProjects.bat
  • The batch file would run premake5.exe using the premake5.lua script
  • Open the generated .sln file in Visual_Studio-2019
  • Build the project

Code

The program is written with scalability in mind. The htmlCalendar class itself is an abstract interface class that can be implemented differently if needed (e.g., For other types calendars, like Julian etc.).

class htmlCalendar {
	public:

		virtual ~htmlCalendar() = default;

		virtual void htmlHead(std::ofstream& myFile) = 0;
		virtual std::string monthBody(const std::string& month) = 0;
		virtual std::string weekDays(int day, int num, int& weekNum) = 0;
		virtual bool isLeapYear(int year) = 0;
		virtual void monthGenerator(std::ofstream& myFile, const std::string& year) = 0;
		virtual void adjYears(std::ofstream& myFile, std::string& year) = 0;
		virtual void htmlEnd(std::ofstream& myFile) = 0;
	};

The namesake class with the Impl suffix provides the implementation for the htmlCalendar generation.

The Disparate Variation formula is used to predict the week day for a given date/year.

However, the formula doesn't account for the fact that the calculated W values can be negative. The program uses a simple fix for that, which is that when the values are negative, it adds 7 to that value, producing the correct number for the week day.

See the function htmlCalendarImpl::monthGenerator(std::ofstream& myFile, const std::string& year) for how the formula is used

The program also keeps into account leap years using the following check:

if (year % 4 == 0)
{
	if (year % 100 == 0)
	{
		if (year % 400 == 0)
			return true;
		else
			return false;
	}
	else
          return true;
  }
  return false;
}

htmlcalendar's People

Contributors

doctor-foxling avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.