ftp.nice.ch/pub/next/tools/workspace/Cassandra.1.7a.s.tar.gz#/Cassandra/calendar.h

This is calendar.h in view mode; [Download] [Up]

//
// calendar.h
// Copyright (c) 1989, 1990 by Jiro Nakamura 
// All rights reserved
//
// Calendar routine package prototypes.
// Actual functions in calendar.m
//
// Note: These are collected from various sources. They may have
// the infamous 1670 bug (or whenever it was). Use only for
// dates that are current (1900+).
//
// RCS Information
// Revision Number->	$Revision: 1.12 $
// Last Revised->	$Date: 90/10/27 17:44:09 $
//

#import <time.h>
#import <stdio.h>

#define	SEC		TRUE
#define	NOSEC	FALSE

/*
	extern const int ayear[13];
	extern const char *months[12];
	extern const char *shortMonths[12];
	extern const char *shortWeekDays[7];
	extern const char *weekDays[7];

*/

// Procedure:		int jan1( int year)
// Arguments:		int year-> the year in question (e.g., 1970, 1971)
// Description:		Returns what day of the week the first day
//			of the year <year> will  be. 
//			(i.e., Jan 1st, <year> will be .......)
// Returns:		an integer from 0..6. (0=Sunday.....6=Saturday)
int jan1( int);


// Procedure:		int daysInMonth( int month, int year)
// Arguments:		int month, int year ->	the month and year in question
// Description:		Returns the number of days in the month and year in question
// Return Value:	The number of days in <month> of <year>.
int daysInMonth(int,int);


// Procedure:		int daysInYear( int year)
// Arguments:		int year ->	the year in question
// Description:		Returns the number of days in the year in question
// Return Value:	The number of days in <year>.
int daysInYear(int);


// Procedure:		int addOne(int month, int year)
// Arguments:		the month and year in question
// Description:		This is a support function. It returns 1 if
//			after the date in question, 1 must be added
//			for leap years. 
// Return Value:	1 if the date is in the year of a leap year,
//			and after Feb 29, 0 if it is not a leap year
//			or it is before Feb 28.
int addOne( int, int);


// Procedure:		int daysUpTo(int month, year)
// Arguments:		the date in question
// Description:		Returns how many days it has been since
//			Jan 1 to the beginning of this month.
// Return Value:	0 - 365
int daysUpTo(int,int);


// Procedure:		int firstDayOf( int month, int year)
// Arguments:		the date in question
// Description:		Returns what day of the week the month
//			in question starts with.
// Return Value:	an integer from 0..6. (0=Sunday.....6=Saturday)
int firstDayOf(int,int);


// Procedure:		int wday( int day, int month,  int year)
// Arguments:		the <day>, <month> and <year> of the date in question
// Description:		Returns the day of the week of the particular date.
//				See ctime(3) for a proper definition of wday.
// Return Value:	an integer from 0..6. (0=Sunday.....6=Saturday)
int wday(int,int,int);


// Procedure:		int yday( int day, int month,  int year)
// Arguments:		the <day>, <month> and <year> of the date in question
// Description:		Returns the index of the date into the year
//				See ctime(3) for a proper definition of yday.
// Return Value:	an integer from 0..365 (366).  0= Jan 1st xxxx, 365(366) = Dec 31, xxxx
int yday(int,int,int);


// Procedure:		int printCalendar( int month, int year,  
//				NXStream *stream)
// Arguments:		the date in question and an open stream	
// Description:		printCalendar will print a monthly calendar like
//			cal(1) for the month and year in question and will
//			dump it to the stream <steram>. 
// Return Value:	0 if an error occured, 1 if all successful.	
int printCalendar(int month, int year, NXStream *stream);


// Procedure:		int printCalendarRTF(int day, int month, 
//				int year,  NXStream *stream
//			char *fontName, float fontSize)
// Arguments:		the date in question and a stream	
// Description:		printCalendarRTF will a RTF version of 
//			a monthly calendar like printCalendar.
//			The day will be highlighted.
// Return Value:	0 if an error occured, 1 if all successful.	
int printCalendarRTF(int day, int month, int year, NXStream *stream,
			char *fontName, float fontSize);


// Procedure:	ascMyTime(struct tm *time, BOOL showSeconds, BOOL militaryTime)
// Arguments:	struct tm *time 	-> the particular time you want printed
//		(BOOL) showSeconds	-> whether you want seconds printed
//		(BOOL) militaryTime	-> whether you want 24hr or am/pm time
// Description:	ascMyTime converts the time structure <time> into an
// 		ascii string in the format:
//		seconds showing->	Mon Jan 11, 1990    5:11:30 pm
// 		seconds hidden->	Mon Jan 11, 1990    5:11 pm
//		<showSeconds> is either TRUE (showing) or FALSE (hidden)
//		militaryTime is either TRUE or FALSE.
// Return value:A constant character pointer to the converted string.
const char * ascMyTime(struct tm *, BOOL showSeconds,  BOOL militaryTime);

// Procedure:	ascMyDate(struct tm *time)
// Arguments:	struct tm *time 	-> the particular date you want printed
// Description:	ascMyDate converts the time structure <time> into an
// 		ascii string in the format:
//			Mon Jan 11, 1990   
// Return value:A constant character pointer to the converted string.
const char * ascMyDate(struct tm *);


// Procedure:	monthFromAscii( char *string)
// Arguments:	char *string		-> the string to analyze
// Description:	monthFromAscii tries its darn hardest to figure out what
//		month <string> refers to. It can understand:
//		jan, Jan, JaN, jAN   ->  mean month 1.
//		1		     ->  means month 1.
//              Thats it! Pretty stupid routine, huh.
// Return Value: The month (an integer) from 1-12.
int monthFromAscii(char *);


// Procedure:	calAsciiCmp( char *a, char *b)
// Scope:	To be used only internally by monthFromAscii
// Arguments:	char *a, char *b
// Description:	Compares string <a> to string <b>, but ignores case
// Return Value: 0 if <a> is the same as <b>	
//		-1 if <a> is before <b> (alphabetically)
//		 1 if <a> is behind <b> (alphabetically)
int calAsciiCmp( char * , char * );


// Procedure:		double secondsBetween( struct tm *a, struct tm* b)
// Arguments:		struct tm *a, *b
// Description:		This will compare the time structures <a> to <b> 
//			and return the number of seconds between the two. 
// Return Value:	The number of seconds seperating the two.
//			Positive if <b> is greater than <a>, 
//			negative if <a> is greater, and 0 if they are the same.
double secondsBetween( struct tm * a, struct tm* b);


// Procedure:		int timeCompare( struct tm *a, struct tm *b)
// Arguments:		time structure <a> and time structure <b>
// Description:		Compares time structure <a> to <b>.
// Return Value:	an integer-> 	-1 if <a> is smaller than <b>
//					 0 if <a> is equal to <b>
//					 1 if <a> is greater than <b>
int timeCompare(struct tm *a, struct tm *b);

// Procedure:		int dayCompare( struct tm *a, struct tm *b)
// Arguments:		time structure <a> and time structure <b>
// Description:		Compares time structure <a> to <b>.
// Return Value:	an integer-> 	-1 if <a> is smaller than <b>
//					 0 if <a> is equal to <b>
//					 1 if <a> is greater than <b>
int dayCompare(struct tm *a, struct tm *b);


// Procedure:		(void) fixTmStructure( struct tm *ts)
// Arguments:		struct tm *ts  -> the time structure to "fix"
// Description:		This will go through and make sure the time 
//			structure is in perfect shape, fix wday 
//			and yday, and allow you to do atrocious 
//			things like:
//				ts.tm_mday += 10;
//			and then fix the structure back up by calling
//			fixTmStructure( &ts)
// Return Value:	void
void fixTmStructure( struct tm *ts);

// Procedure:		const struct tm *timeNow()
// Description:		Returns a pointer to a structure which contains the 
//			present time
// Return Value:	(struct tm *) -> a pointer to the structure
const struct tm *timeNow();

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.