Click here to Skip to main content
13,258,604 members (47,473 online)
Click here to Skip to main content
Articles » Database » Database » General » Downloads


56 bookmarked
Posted 30 Nov 2003

DarkSide SQL Mini Version 1, The embedded database

, 23 Mar 2006
An embedded database library in C++.
// mydate.h
// defines a date type
// Date: 28 Aug 2003 12:04 AM
// Last Modified: 28 Aug 2003 12:04 AM
// Author: Vijay Mathew Pandyalakal

/* Copyright 2000 - 2005 Vijay Mathew Pandyalakal.  All rights reserved.
 * This software may be used or modified for any purpose, personal or
 * commercial.  Open Source redistributions are permitted.  
 * Redistributions qualify as "Open Source" under  one of the following terms:
 *    Redistributions are made at no charge beyond the reasonable cost of
 *    materials and delivery.
 *    Redistributions are accompanied by a copy of the Source Code or by an
 *    irrevocable offer to provide a copy of the Source Code for up to three
 *    years at the cost of materials and delivery.  Such redistributions
 *    must allow further use, modification, and redistribution of the Source
 *    Code under substantially the same terms as this license.
 * Redistributions of source code must retain the copyright notices as they
 * appear in each source code file, these license terms, and the
 * disclaimer/limitation of liability set forth as paragraph 6 below.
 * Redistributions in binary form must reproduce this Copyright Notice,
 * these license terms, and the disclaimer/limitation of liability set
 * forth as paragraph 6 below, in the documentation and/or other materials
 * provided with the distribution.
 * The Software is provided on an "AS IS" basis.  No warranty is
 * provided that the Software is free of defects, or fit for a
 * particular purpose.  
 * Limitation of Liability. The Author shall not be liable
 * for any damages suffered by the Licensee or any third party resulting
 * from use of the Software.

#ifndef _MYDATE_H 
#define _MYDATE_H


namespace openutils {

class MyDate {
    int m_nYear;
    int m_nMonth;
    int m_nDay; 

	int m_nOldYear;
	int m_nOldMonth;
	int m_nOldDay;

		// constrcutors
		MyDate(const char* date);
		MyDate(int d,int m,int y);

		// set value functions
		void setDate(const char* date);
		void setYear(int y);
		void setMonth(int m);
		void setDay(int d);

		// get functions
		int getYear();
		int getMonth();
		int getDay();    
		string getShortMonth();
		void getFullMonth(char* ret);		
		string getDate();
		string getDate(const char* format);

		// arithmetic functions
		void addDays(int d);
		void addMonths(int m);
		void addYears(int y);		
		void lessDays(int d);
		void lessMonths(int m);
		void lessYears(int y);
		int differenceInDays(MyDate d);
		int differenceInMonths(MyDate d);
		int differenceInYears(MyDate d);
		// operators
		bool operator > (MyDate d);
		bool operator < (MyDate d);
		bool operator == (MyDate d);
		bool operator != (MyDate d);
		void operator = (MyDate d);
		void operator = (char* c);
		// overloaded comparison functions
		bool lesserThan(MyDate d) {
			return (*this < d);
		bool greaterThan(MyDate d) {
			return (*this > d);
		bool equals(MyDate d) {
			return (*this == d);
		bool notEquals(MyDate d) {
			return (*this != d);
		// utilities		
		bool isLeapYear();

		void validate();
		int getDaysInMonth();
		void correctDays();
		void restore();	

class MyDateException {
		string m_strErr;
		MyDateException() { m_strErr = ""; }
		MyDateException(string s) { m_strErr = s; }		
		string getMessage() { return m_strErr; }
		void setMessage(string s) { m_strErr = s; }

} // namespace myutils


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 23 Mar 2006
Article Copyright 2003 by AnOldGreenHorn
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid