Is there any use to using Julian Dates in code?

I support a PHP / Flash application that uses Julian dates inside code and only converts to Gregorian for display. Before replacing integer Julian dates with Date data type, I was wondering if there is an advantage to using Julian? If that even changes?

One of the problems is the ability to quickly search for dates in the database. I added a Date-Time Stamp to one of the tables to fix this, but now we are moving to a new database and are able to make improvements, so deviating from the Julian date seems like what needs to be done. So why don't I want to do this? The original developer is no more.

+4
source share
4 answers

To control the date and time, you want all of your moments to use a simple, monotonous linear scale. People’s calendars, time zones, daylight saving time, they make things more complicated and are best stored at the display level.

The overall scale is the encoding of moments in the form of a few seconds (or milliseconds) from a specific origin. In Java, you will use milliseconds from January 1, 1970 at 00:00:00 UTC (also called the "Epoch"); you also ignore the seconds of the jump, so conversions to any date and time on any calendar are purely algorithmic. This scale returns System.currentTimeMillis() . In the Unix world, you can use the number of seconds since Epoch, since it is that the Unix kernel is subject to return (via the time() system call).

Such linear scales make it easy to compare dates and calculate time intervals, while any calendar calculations make such calculations difficult.

So, my advice would be to move away from the Julian dates, but, of course, do not turn them into Gregorian dates. On the contrary, in fact.

+5
source

Julian Dates, I know this php-oriented question would be more suitable for large billing systems running on Mainframes, especially in COBOL, this is just to simplify the calculation of days from the beginning of billing to the end of billing. This is the only thing I can think of where Julian Dutt's words are used, especially in legacy COBOL codes ... I'm not 100% sure of what is being used now, I would present the correct formatted dates (Y2K error was a nonexistent thing that was incredible bloated!) ...

Hope this helps, Regards, Tom.

+2
source

I see no reason not to use the Date class. You can go back and forth between unixtime (although flash uses milliseconds instead of seconds) it is very easy to use this, so I would recommend using back and forth for communication.

And one more happened; If you decide to use regular unixtime, you cannot use int / uint data types in Flash because they will overflow, you will have to use Number.

+1
source

numeric dates such as Julian dates or the Unix era are much easier to calculate ... time in n hours or time difference between two arbitrary dates can be easily calculated ...

0
source

Source: https://habr.com/ru/post/1301712/


All Articles