| | |
gregorian calendar, help
![]() |
•
•
Join Date: Mar 2008
Posts: 11
Reputation:
Solved Threads: 0
Hello Geeks,
I am working on a program for date,month calculation.
I found this code used to convert to Gregorian format for calculation.
It would be great full for me if anybody can explain this ... like 0.75 yy/4 .4*mm what are these constants why m-1, yy-1 etc..
Thankyou
I am working on a program for date,month calculation.
I found this code used to convert to Gregorian format for calculation.
It would be great full for me if anybody can explain this ... like 0.75 yy/4 .4*mm what are these constants why m-1, yy-1 etc..
C Syntax (Toggle Plain Text)
long xx; int yy,dd,m; xx = 365 + yy +dd+31*(m-1) if(m<3) xx= xx+((yy-1)/4)-(0.75*(yy-1)/100 + 1); else xx = xx-(0.4*mm+2.3)+(yy/4)-(0.75*(yy/100)+1));
Last edited by modaslam; Mar 21st, 2008 at 7:58 am.
•
•
Join Date: May 2004
Posts: 178
Reputation:
Solved Threads: 10
I have no idea why the original coder wrote that stuff, except it appears the s/he did not know about the standard C library date/time functions.
date arithmetic is best done with that library - convert a date/time to a struct tm, convert the struct tm to epoch seconds. Do the same thing with another time or date. Now you can add subtract or whatever - like what date & time was it 48 days ago? You don't have to worry about leap years, for example.
Work backwards to get a new date.
The functions you need are
gmtime or localtime
mktime
strftime
You also have to learn what goes into struct tm, so you can build one if your system does not have strptime.
here is some help:
http://publications.gbdirect.co.uk/c..._and_time.html
date arithmetic is best done with that library - convert a date/time to a struct tm, convert the struct tm to epoch seconds. Do the same thing with another time or date. Now you can add subtract or whatever - like what date & time was it 48 days ago? You don't have to worry about leap years, for example.
Work backwards to get a new date.
The functions you need are
gmtime or localtime
mktime
strftime
You also have to learn what goes into struct tm, so you can build one if your system does not have strptime.
here is some help:
http://publications.gbdirect.co.uk/c..._and_time.html
Last edited by jim mcnamara; Mar 21st, 2008 at 2:27 pm.
•
•
Join Date: Mar 2008
Posts: 11
Reputation:
Solved Threads: 0
•
•
•
•
I have no idea why the original coder wrote that stuff, except it appears the s/he did not know about the standard C library date/time functions.
date arithmetic is best done with that library - convert a date/time to a struct tm, convert the struct tm to epoch seconds. Do the same thing with another time or date. Now you can add subtract or whatever - like what date & time was it 48 days ago? You don't have to worry about leap years, for example.
Work backwards to get a new date.
The functions you need are
gmtime or localtime
mktime
strftime
You also have to learn what goes into struct tm, so you can build one if your system does not have strptime.
here is some help:
http://publications.gbdirect.co.uk/c..._and_time.html
Actually the program is to find the days elapsed between to given days.
The code snippet i have given is to convert the normal date to Gregorian type.
what they have explained is first they take two days and convert to Gregorian type.
and subtract second from first. so that they can get the difference in days elapsed
To convert a normal date to Gregorian type they used this function.
•
•
Join Date: Dec 2007
Posts: 6
Reputation:
Solved Threads: 0
I am wondering if we can build a calendar in C language...
...as in Gregorian Calendar format and design
Is there any code that could help me to print or to display a Gregorian Calendar???
pls. reply... thanks... God bless...
my yahoo email add is: email snipped
...as in Gregorian Calendar format and design
Is there any code that could help me to print or to display a Gregorian Calendar???
pls. reply... thanks... God bless...
my yahoo email add is: email snipped
Last edited by WolfPack; Mar 24th, 2008 at 12:16 pm. Reason: Removed email address per forum rules.
•
•
Join Date: Mar 2008
Posts: 11
Reputation:
Solved Threads: 0
•
•
•
•
I am wondering if we can build a calendar in C language...
...as in Gregorian Calendar format and design
Is there any code that could help me to print or to display a Gregorian Calendar???
pls. reply... thanks... God bless...
my yahoo email add is: email snipped
okay
Last edited by WolfPack; Mar 24th, 2008 at 12:17 pm. Reason: Removed email from quoted message.
![]() |
Similar Threads
- Gregorian Calendar...need help pls. (Java)
- Hijri Calendar value in visual basic (Visual Basic 4 / 5 / 6)
- gregorian to julian in python (Python)
- The Gregorian Calendar (C++)
- 2038 Problem (C++)
- Calendar Creator (C)
- help with sort using Calendar class getting null pointer exception (Java)
Other Threads in the C Forum
- Previous Thread: Combinations of a string using Recursion(Modified Version)
- Next Thread: header file confusion
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






