Converting Julian Day to Month and Date: A C Pointer Problem Solution

  • Thread starter kant
  • Start date
In summary, the programmer is trying to create a program that will convert a julian day and given year to the mouth and date of that year. The programmer needs a list of the number of days in each month for a whole year as well as a list of the number of days in each month for a given year. If the length of the month is greater than the number of days left in the given year, the month name is taken and the number of days is the day of the month. If the number of days is greater than the month, the programmer subtracts the month and makes the next month the current month. The programmer then tries to change the English into pseudocode to describe how the code will work.
  • #1
kant
388
0
One of the problems on pointers in my textbook is this:

Create a program that would convert a julian day and given year, and convert it to the mouth and date of that year.

How to do this problem?

Solution is in the form of pseudocode
 
Last edited:
Computer science news on Phys.org
  • #2
kant said:
One of the problems on pointers in my textbook is this:

Create a program that would convert a julian day and given year, and convert it to the mouth and date of that year.

How to do this problem?

Solution is in the form of pseudocode

What do you have to show us as far as the work you have done so far?
 
  • #3
ComputerGeek said:
What do you have to show us as far as the work you have done so far?


well, this is summer so there is really no school. I am just trying to make friend with that textbook. It is not an assignement, so there is really no requirement. In fact, i don t even know were to find a solfwere where i can create the source code and run it( perhaps you can help?).
 
  • #4
  • #5
That s a great link , thank you.
 
  • #6
kant said:
well, this is summer so there is really no school. I am just trying to make friend with that textbook. It is not an assignement, so there is really no requirement. In fact, i don t even know were to find a solfwere where i can create the source code and run it( perhaps you can help?).

Install Debian Linux or Fedora Linux. all the dev tools you ned are right there.

Dev-C++ is good, but it seems to have been unmaintained since before I had used it 4 years ago.
 
  • #7
Its better than switching platforms entirely
 
  • #8
Grotesque Puppet said:
Its better than switching platforms entirely

:-)

That is debatable :-p

Personally, I find that the time I spent learning to use Linux was time well spent because I have discovered just how inefficient Windows is as far as getting work done.

but this should not turn into an OS flame fest.

it is just to bad that on windows there are no free programming editors that support as many languages as Subethaedit on OS X or even gedit or Kate or nedit on Linux... though Subethaedit is my favorite because of its clean interface.

the best free editor on Windows is crimson editor I think. I used it a lot on my HP laptop before I got my iBook.
 
  • #9
kant said:
One of the problems on pointers in my textbook is this:

Create a program that would convert a julian day and given year, and convert it to the mouth and date of that year.

How to do this problem?

Solution is in the form of pseudocode


anyway, back on topic.

you do not need a development tool to prototype it in pseudo-code. just use paper and pencil since you are simply using made up commands to describe how the code will work.
 
  • #10
The "julian day" you seem to mention is just the number of days in the year - ie.,
February 5, 2005 is the 36th day of 2005. In computerese it's called the year-day or day of the year.

What you need is a list of the number of days in each month for a whole year -
with February having either 28 or 29 days, to handle a leap year.

Then, work down the list of months (taking into account which version of February to use) by:
top:
Compare number of "julian" days to length of the month.
If the length of the month is greater than the days left, you have the month name
and the number of days is the day of the month. Exit at this point.
If the number of days is greater than the month, subtract the month, make the next month in the list the current month
(remember the February problem? Is this a leap year, yes or no? Is the month February?).
next, go to top

Now try to change the English into pseudocode.

If the Julian date really is a Julian date, and not a year-day, then you need to know which Julian date system is being used. Days since Jan 1, 1857, days since the current epoch, or days since Dec 31, 4713 BC? And then you have a far tougher problem. And it may include the 'short September 1752' problem if you live in the US.

see:
http://www.dome-igm.com/convers.htm
 
Last edited by a moderator:

1. What is Julian Day?

Julian Day is a continuous count of days since January 1, 4713 BC in the Julian calendar. It is commonly used in astronomy and is a way to represent dates without using a specific calendar system.

2. Why would I need to convert Julian Day to Month and Date?

Some scientific calculations and data may be represented in Julian Day, so converting it to the more common month and date format can make the data easier to interpret and use. Additionally, some programming languages may not have built-in functions to work with Julian Day, so conversion may be necessary to perform certain operations.

3. What is a C pointer problem and how does it relate to converting Julian Day?

A C pointer problem is an issue that can occur when working with pointers in the C programming language. In this specific context, it refers to difficulties in converting Julian Day to month and date, which often involves using pointers to manipulate memory addresses and perform calculations.

4. How can I convert Julian Day to Month and Date using C pointers?

One solution is to first convert the Julian Day to the corresponding day in the Gregorian calendar, then use pointers to extract the month and date from that day. The exact steps may vary depending on the specific implementation and programming language used.

5. Are there any other methods for converting Julian Day to Month and Date?

Yes, there are other methods for converting Julian Day to Month and Date, such as using built-in functions or libraries in certain programming languages. Some online converters and calculators are also available for this purpose. However, understanding the underlying logic and using C pointers can be helpful for those working with the data in a more complex or customized way.

Similar threads

  • Computing and Technology
Replies
10
Views
840
  • Computing and Technology
Replies
7
Views
369
  • Computing and Technology
Replies
9
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
1K
  • Biology and Chemistry Homework Help
Replies
6
Views
467
  • Computing and Technology
Replies
25
Views
3K
  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Programming and Computer Science
2
Replies
40
Views
2K
  • Programming and Computer Science
Replies
14
Views
1K
Replies
8
Views
2K
Back
Top