Shell Unix time vs. Christ time

Hello guys,

consider the unix time: 0xf3876b47 (as it is stored in the filesystem)

Because the data is organized according to the Little Endian system, to turn it into a readable format, I must first put the bytes in the correct order, 0×476b87f3, then turn it into base ten, 1198229491, and at this point convert the Unix Time into a "human" time.

Please, can you tell me the conversion formula ?

Thanks in advance.

Vincenzo.
 
0x476b87f3 or 1198229491, it's the same value - the first is what you get from printf %x, the second from printf %d. So the first part is easy - at your shell prompt, type "printf '%d\n' 0x476b87f3" and you will see what I mean.

Where did that 0x476b87f3 come from, I mean, what command or program? You've marked this as "shell" - this is an sh script? If you really need to process a integer time_t date string and get a ctime(3) date string, it might go a lot easier if part or all of it could be done in an application programming language, like C, python etc.
 
Thanks a lot Donn, but the number 0xf3876b47 is a data (day of week, day of mounth, mounth, year, hour:minute:seconds) GMT. What this date is ? and which is the computation formula ?

Regards.

Vincenzo.
 
Please, can you tell me the conversion formula ?
Maybe I am a bit byes as an astronomer by my undergrad training but It is probably easier to use Julian date of the Julian epoch as intermediate step.

http://scienceworld.wolfram.com/astronomy/JulianDate.html
http://scienceworld.wolfram.com/astronomy/JulianEpoch.html

before converting to UNIX epoch. Check out this blog

http://www.kirix.com/stratablog/converting-julian-dates-and-unix-timestamps

For anything time related the main reference is Nautical Almanac of the U.S. Naval observatory which we used in Eastern Europe as well when I was growing up :)

http://aa.usno.navy.mil/publications/docs/almanacs.php

Your local university should have a copy.
 
What that number is: the seconds, since the beginning of the epoch, which was roughly 1970. So you could get close, knowing how many seconds there are in a day, how many days there are in a year, etc. If you're desperate to do it that way, you could probably make it work. But it's a lot easier, and more reliable, to let ctime(3) do it for you.
 
Unix time stamps are fundamentally the number of seconds since January 1st, 1970, in GMT. The reality is heinously complicated, because of things like time zones, daylight savings time, leap seconds, leap years, and so on. There are LOTS of writeups on the web about how this works. The conversion formula is complicated.

Here is an easy way to do it:
> python
>>> import time
>>> t=0x476b87f3
>>> t
1198229491
>>> time.ctime(t)
'Fri Dec 21 01:31:31 2007'

And don't ask me what time zone the output is in. Read the python documentation about how to specify time zones.
 
Thanks very much guys !

Ralph, I'll translate the code you wrote in c (I don't know pyton). However, the yours is the correct reply ... I'll go to study ctime(t).

Thanks !!!
 
For a shell script, have a look at date -r in date(1):

Code:
% date -r 0xf3876b47
So. 21 Juni 2099 17:18:31 CEST

date will take into account the local timezone settings (and DST) of the system it runs on, so you won't have to deal with this yourself.

For C you might have a look at strftime(3) and/or strptime(3)
 
OT:
vince66
In your headline you use the term "Christ time". Can you enlighten us about that?
I also wondered, as I thought maybe vince66 meant to make clear that he didn't mean the Islamic calendar.
Then I asked myself, whether in Islamic countries they convert from/to Islamic time on their PCs.
But I didn't find anything in the web when doing a quick search...
 
vince66
In your headline you use the term "Christ time". Can you enlighten us about that?

It's referring to the Julian and Gregorian calendars -- B.C. (before Christ), A.D. (anno Domini):

The term anno Domini is Medieval Latin and means "in the year of the Lord",[7] but is often presented using "our Lord" instead of "the Lord",[8][9] taken from the full original phrase "anno Domini nostri Jesu Christi", which translates to "in the year of our Lord Jesus Christ".
https://en.wikipedia.org/wiki/Anno_Domini
 
Thank you for trying to jump in for vince66, but this does not satisfies the question. People usually choose the wording of a headline carefully, and this is an IT related forum dedicated to FreeBSD using RFC and ISO when dealing with time. As such we are committed to precise terms. Think about the attempt to write an algorithm for "Christ time", shouldn't we know for sure what we are talking about?

As we all know there is a decent difference between calendar and time, and the OP did not mention calendar. As there is still room for wild speculations how the term "Christ time" could be interpreted, only vince66 could give us some relief. Doesn't he owe this to us?

Haha. I don't feel owed anything. :p

To me it reads "Unix time vs Human time," seeing as we humans use Christ's birth to delineate time. Think of it as "Unix epoch vs Christ epoch."
 
Yeah, this was not addressed to you, and I do not feel being addressed by your emoticon.

If you're going to get so hung up on using precise terms to avoid ambiguity, then you shouldn't be using "us" unless you really mean "us": "Doesn't he owe this to us?" No, I don't feel he owes it to me, a member of "us."

There's no "wild speculation" necessary, either. What I've posted above as a possible explanation stands pretty solidly, and you haven't given a counter-argument for why it doesn't. It shouldn't be so hard to make the connection between the use of the term "Christ time" and how it applies to what we refer to as "time" -- which is based on the Julian and Gregorian calendars. I mean, the interconnection is obvious.
 
Hello guys !

I've read with interest your scientific proposal solutions and scientific articles suggested me. I wish to thank you for this.
However the problem is not completely solved.

I'll try to explain it.

I've done this test.

I've plugged a usb stick into a FreeBSD workstation and mounted it (read only). The "dates of last modify" of the files are not the same shown by a Windows workstation that shows them delayed by 1 hour.

So the question is: which are the true dates ?

If you agree with me that the date information is stored in the filesystem, the previous question can be posed as:

the "time zero" for Unix is: January 1st, 1970
the "time zero" for Windows is: 12:00 A.M. January 1, 1601
which is the files's date stored on the usb stick filesystem respect the Universal Time of the Christ birth ?

Thanks for your time.

Regards.
 
I've done this test.

I've plugged a usb stick into a FreeBSD workstation and mounted it (read only). The "dates of last modify" of the files are not the same shown by a Windows workstation that shows them delayed by 1 hour.

So the question is: which are the true dates ?

If you agree with me that the date information is stored in the filesystem, the previous question can be posed as:

the "time zero" for Unix is: January 1st, 1970
the "time zero" for Windows is: 12:00 A.M. January 1, 1601
which is the files's date stored on the usb stick filesystem respect the Universal Time of the Christ birth ?

Your choice of title has caused quite a stir, vince66. :D

Can you post an example? stat a file on that USB drive on FreeBSD, then stat it on the Windows machine using cygwin (you do run cygwin, right? I can't do any work on Windows without it). Or if you're running Win10 you can use the Linux subsystem (so I've heard) to get the stat.
 
which is the files's date stored on the usb stick filesystem respect the Universal Time of the Christ birth ?
It has nothing to do with Christ's birth. It has only a tiny bit to do with the origin of the Julian / Gregorian calendar (note that Julius Caesar, who performed the calendar reform, died in about 40 b.c.).

It has everything to do with time zones, daylight savings time, and the fact that a FAT file system stores the file time stamps in local time, which makes the meaning of the stored data time zone dependent. This is different from all Unixes, where the time stamps on files are usually stored in UTC, which makes the display of the stored data (but not its meaning) time zone dependent. The one hour discrepancy is probably caused by some operating system using a different definition of daylight savings time.

Fully explaining this would require writing a 5-page essay, and you can easily find that on the web.
 
It has nothing to do with Christ's birth. It has only a tiny bit to do with the origin of the Julian / Gregorian calendar (note that Julius Caesar, who performed the calendar reform, died in about 40 b.c.).

The OP's use of "Christ time" had everything to do with Christ's birth. I mentioned the Julian and Gregorian calendars because we number years in those calendars using Christ's birth as the epoch, AD 1 -- which is where I thought the OP got his idea of "Christ time."

But "Universal Time of the Christ birth" leads me to believe he assumed the abbreviation "UTC" referenced that event, which of course it does not.
 
Hello guys,

briefly in which year do we live?

2017

This number means: two thousand and seventeen years after the birth of Christ.

That is: the birth of Christ is the "time zero" for the whole humanity.

All the other definitions of Calendars, UTC, CET,CEST, Julian and not Julian have consequently been arranged.

Julian day number 0 is assigned to the day starting at noon on Monday, January 1, 4713 BC.
OK.
But tell me now if, this morning, you go to the airport and read that your flight takes off on December 21st 6730 (4713+2017) :):):p:p:D;)
What do you do ? :eek::eek::eek::oops::oops::mad::mad:

This is the truth; it is useless to disguise it.

Back to scientific and more prolific topics.

Ralph, I well know that the problem is the timezone and I'm agree with you.

But my question is:

Is the timezone information stored in the filesystem, when I create a file ? or not ? It seems to me that the reply is no (for FAT and NTFS filesystems). Or I'm wronging and I have not well understood the fields of the filesystem structure ?
Without time zone information, it seems to me that the date of a file does not univocally determine its creation, last modification, etc ..

Thanks in advance guys !
 
For precise and correct time measurement/designation, an alleged event somewhere around 2000 years ago is as useless as measuring distances in "3 grains of barley" increments. So the definition of some point in the (well known and documented!) past is much more reliable. How far back this point is defined is essentially unimportant as it is just a fixed point from which you can go back and forth. A "date" like "october 3rd 1420" is just a mere concept and varies a lot through different countries/cultures etc ("43th day in the year of the unicorn") and even simply telling the time of day might cause confusion due to different concepts (I don't know if there is an equivalent in the english language, but in german there is e.g. "viertel drei / quarter three", which can be 2:15; 2:45 or even 3:15 depending on the region you are...).

On the other hand, the notation "N seconds before/after a commonly agreed on and well defined fixed point" is universal. How far near or back that fixed point lays is irrelevant, as you can back and forth as you like without loosing precision, hence it is more critical to get that point very well and precisely defined than to put it as far back as possible.
A "second" is precisely defined via a natural constant (radioactive decay of Cs 133), which is exactly the same anywhere in the universe. So given a precise measurement and record of "seconds past since the agreed on fixed point", any point in time can be precisely named/defined and understood anywhere. (yes, we could brag about relativistic time dilatation, but let's not open that can of worms...)
 
Please, linux->bsd, is there an alternative way to get an equivalent "stat" command on Windows ? I'm not interested to install cygwin on my Windows 7 machine.

Thanks !!
 
That is: the birth of Christ is the "time zero" for the whole humanity.
That is, with all respects blunt nonsense and hubris. That may sadly be true for those who lack some decent knowledge and who are probably caught in a religious egocentric view of the world.

Also note that Dionysius the Humble invented what is known as "Anno Domini". The "Anno Domini" era became dominant in western Europe only after it was used by the Venerable Bede to date the events in his Ecclesiastical History of the English People, completed in 731. That only could happen because of the deeply dominant religious context in medieval Europe of that time when people still were tortured and killed for their scientific works.

For solving your "problem" there is absolutely no need to refer to nonsense terms like "Christ time" which obviously originate from some religious idiosyncrasy, not appropriate for tech talk.
 
Please, linux->bsd, is there an alternative way to get an equivalent "stat" command on Windows ? I'm not interested to install cygwin on my Windows 7 machine.

Thanks !!

Right-click on a file, and select "Properties." Under the "General" tab you'll see "Created," "Accessed," "Modified."
 
Is there the possibility that English is not their first language and you are reading far more into it than needed? Anyway, there's lots of places to discuss that and it seems pretty irrelevant to the original (TECHNICAL, cough cough) question.
 
Pls, linux->bsd, before stat the same file on the FreeBSD and Windows OS, let me align the two machines in time. In the attached picture you can see the timezone on my Windows machine. It is UTC+1.
If I type date on my FreeBSD machine I obtain the UTC time. Please, tell me how can I change the timezone on FreeBSD to UTC+1. Which .conf file I need to modify ?
Thanks.
 

Attachments

  • Timezone_on_my_Windows7_PC.png
    Timezone_on_my_Windows7_PC.png
    60.1 KB · Views: 465
scottro, any problem ? what seems to you is not important. What is developed in this post are intermediate steps to reach a solution tothe original question. So ...

Regards !
 
Back
Top