strftime and julianday

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

strftime and julianday

Stephen Chrzanowski
Messing around tonight with a work project, dealing with times, I noticed
the following:

C:\Users\Stephen>sqlite3
SQLite version 3.8.10.1 2015-05-09 12:14:55
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select strftime('%H:%M',0.0);
12:00

I would have expected 0:00, not 12:00.  Does this tie into julianday being
a 12 hour offset?

I'll either adjust the actual query I'm working on, or scrap it and have
the program deal with converting minutes to Hours:Minutes.  (Kind of
thinking the later, since I don't seem to be able to get a zero day output)
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Richard Hipp-3
On 9/27/17, Stephen Chrzanowski <[hidden email]> wrote:

> Messing around tonight with a work project, dealing with times, I noticed
> the following:
>
> C:\Users\Stephen>sqlite3
> SQLite version 3.8.10.1 2015-05-09 12:14:55
> Enter ".help" for usage hints.
> Connected to a transient in-memory database.
> Use ".open FILENAME" to reopen on a persistent database.
> sqlite> select strftime('%H:%M',0.0);
> 12:00
>
> I would have expected 0:00, not 12:00.  Does this tie into julianday being
> a 12 hour offset?
>

https://en.wikipedia.org/wiki/Julian_day

Julian days start at noon.  So, yes, 0.0 is noon.  If you want
midnight, that's 0.5.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Igor Tandetnik-2
In reply to this post by Stephen Chrzanowski
On 9/27/2017 8:06 PM, Stephen Chrzanowski wrote:

> Messing around tonight with a work project, dealing with times, I noticed
> the following:
>
> C:\Users\Stephen>sqlite3
> SQLite version 3.8.10.1 2015-05-09 12:14:55
> Enter ".help" for usage hints.
> Connected to a transient in-memory database.
> Use ".open FILENAME" to reopen on a persistent database.
> sqlite> select strftime('%H:%M',0.0);
> 12:00
>
> I would have expected 0:00, not 12:00.  Does this tie into julianday being
> a 12 hour offset?

Yes. A Julian day starts at noon, not midnight. strftime('%H:%M',-0.5); would give you midnight of that day.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Stephen Chrzanowski
Perfect.  Thanks guys.  Thanks Igor for the proper offset as well.  I'll
file that for later reference. :]

On Wed, Sep 27, 2017 at 8:13 PM, Igor Tandetnik <[hidden email]> wrote:

> On 9/27/2017 8:06 PM, Stephen Chrzanowski wrote:
>
>> Messing around tonight with a work project, dealing with times, I noticed
>> the following:
>>
>> C:\Users\Stephen>sqlite3
>> SQLite version 3.8.10.1 2015-05-09 12:14:55
>> Enter ".help" for usage hints.
>> Connected to a transient in-memory database.
>> Use ".open FILENAME" to reopen on a persistent database.
>> sqlite> select strftime('%H:%M',0.0);
>> 12:00
>>
>> I would have expected 0:00, not 12:00.  Does this tie into julianday being
>> a 12 hour offset?
>>
>
> Yes. A Julian day starts at noon, not midnight. strftime('%H:%M',-0.5);
> would give you midnight of that day.
> --
> Igor Tandetnik
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Keith Medcalf
In reply to this post by Stephen Chrzanowski
>I would have expected 0:00, not 12:00.  Does this tie into julianday
>being a 12 hour offset?

Six centuries or so ago it was "kind of difficult" to measure when the sun was "directly underfoot" at the prime meridian (0 deg, or Greenwich England, more or less) when your observation point was located on the prime meridian.  It was pretty easy however to be able to tell when "noon" is (when the sun is at its maximum altitude) by an observer at the prime meridian.  So the juliandate is measures a day from noon to noon.  The modified Julian Day uses a "day" going from midnight to midnight at the prime meridian (by that time arithmetic had been invented so it was possible to calculate "midnight" even though you cannot see through the earth).

:)





_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Keith Medcalf

That is of course ~6.5 thousand years or ~65 centuries.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Keith Medcalf
>Sent: Wednesday, 27 September, 2017 19:52
>To: SQLite mailing list
>Subject: Re: [sqlite] strftime and julianday
>
>>I would have expected 0:00, not 12:00.  Does this tie into julianday
>>being a 12 hour offset?
>
>Six centuries or so ago it was "kind of difficult" to measure when
>the sun was "directly underfoot" at the prime meridian (0 deg, or
>Greenwich England, more or less) when your observation point was
>located on the prime meridian.  It was pretty easy however to be able
>to tell when "noon" is (when the sun is at its maximum altitude) by
>an observer at the prime meridian.  So the juliandate is measures a
>day from noon to noon.  The modified Julian Day uses a "day" going
>from midnight to midnight at the prime meridian (by that time
>arithmetic had been invented so it was possible to calculate
>"midnight" even though you cannot see through the earth).
>
>:)
>
>
>
>
>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Simon Slavin-3
In reply to this post by Keith Medcalf


On 28 Sep 2017, at 2:51am, Keith Medcalf <[hidden email]> wrote:

>> I would have expected 0:00, not 12:00.  Does this tie into julianday
>> being a 12 hour offset?
>
> Six centuries or so ago it was "kind of difficult" to measure when the sun was "directly underfoot" at the prime meridian (0 deg, or Greenwich England, more or less) when your observation point was located on the prime meridian.  It was pretty easy however to be able to tell when "noon" is (when the sun is at its maximum altitude) by an observer at the prime meridian.  So the juliandate is measures a day from noon to noon.

Yet humans still don’t like talking about the number zero.  So it’s still called "twelve o’clock" by everyone except programmers.  As is midnight.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Stephen Chrzanowski
I knew that over the course of human history, the calendar and time
'evaluations' were changed more than twice.  What caught me off guard was
that strftime was treated with the same ambiance to julianday as being
+12hr from midnight when I thought I was asking for a midnight time value.

This is just one of those things that I'll need to keep in the back of my
mind when playing with this.  Right now, my work project is dealing with
time differences with the resolution of minutes.  The 12hour thing doesn't
affect me.

As a matter of fact, I started to work with doing my time deltas using
julianday, but, I ran into some float rounding issues and the math was
shorting me by at least a second, which made 1 hour look like 59 minutes.
Switched to strftime('%s',...) to do the math based on seconds and I've got
more than enough resolution for what I'm doing.


On Wed, Sep 27, 2017 at 10:01 PM, Simon Slavin <[hidden email]> wrote:

>
>
> On 28 Sep 2017, at 2:51am, Keith Medcalf <[hidden email]> wrote:
>
> >> I would have expected 0:00, not 12:00.  Does this tie into julianday
> >> being a 12 hour offset?
> >
> > Six centuries or so ago it was "kind of difficult" to measure when the
> sun was "directly underfoot" at the prime meridian (0 deg, or Greenwich
> England, more or less) when your observation point was located on the prime
> meridian.  It was pretty easy however to be able to tell when "noon" is
> (when the sun is at its maximum altitude) by an observer at the prime
> meridian.  So the juliandate is measures a day from noon to noon.
>
> Yet humans still don’t like talking about the number zero.  So it’s still
> called "twelve o’clock" by everyone except programmers.  As is midnight.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime and julianday

Simon Slavin-3


On 28 Sep 2017, at 4:12am, Stephen Chrzanowski <[hidden email]> wrote:

> As a matter of fact, I started to work with doing my time deltas using
> julianday, but, I ran into some float rounding issues and the math was
> shorting me by at least a second, which made 1 hour look like 59 minutes.
> Switched to strftime('%s',...) to do the math based on seconds and I've got
> more than enough resolution for what I'm doing.

I think that that’s a very good solution.  I prefer working with integers to reals where possible.  Far easier to figure out the possibilities.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users