Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Date and Time library
Mon, Mar 25 2019 12:16 PMPermanent Link

Matthew Jones

I think it would be helpful to have a full set of functions for managing dates and times. Could be generated by us users, or by Tim. But right now I'm having to revisit my own library because it is giving values of 2089 when adding a date and a time.

I sort of need things that can take a DateTime and give me a Date, to which I can add a Time, or add three hours, or three days, or whatever makes sense.

I can't remember what the change was that happened - was it that times always have a date on them? How do I get that to not have the date? The help doesn't describe the underlying data for me to manipulate.

--

Matthew Jones
Mon, Mar 25 2019 12:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< I think it would be helpful to have a full set of functions for managing dates and times. Could be generated by us users, or by Tim. But right now I'm having to revisit my own library because it is giving values of 2089 when adding a date and a time. >>

DateTimes are just integers (msecs) relative to midnight, January 1, 1970.

<< I sort of need things that can take a DateTime and give me a Date, to which I can add a Time, or add three hours, or three days, or whatever makes sense. >>

Noted.  You can do that now, but it involves some conversions to msecs for the relevant offset (day, hour, etc.) and then adding them to/subtracting them from the source DateTime.

<< I can't remember what the change was that happened - was it that times always have a date on them? >>

It depends upon how they are created.  If you create a time using the Time() function, then the DateTime *will* include the date portion.

I've updated the manual so that it specifies the exact behavior for the Date() and Time() functions, and you can see them online here:

https://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Date

https://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Time

<< How do I get that to not have the date? The help doesn't describe the underlying data for me to manipulate. >>

These functions have been in the WebCore unit for a bit:

  function StripDate(Value: DateTime; UTC: Boolean=False): DateTime;
  function StripTime(Value: DateTime; UTC: Boolean=False): DateTime;

However, stripping the date portion of a DateTime is a fairly useless exercise, based upon my experience.  It doesn't really add any value, and prevents the times from being properly localized, if one so desires.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Mar 25 2019 12:57 PMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> These functions have been in the WebCore unit for a bit:
>
>    function StripDate(Value: DateTime; UTC: Boolean=False): DateTime;
>    function StripTime(Value: DateTime; UTC: Boolean=False): DateTime;
>
> However, stripping the date portion of a DateTime is a fairly useless exercise, based upon my experience.  It doesn't really add any value, and prevents the times from being properly localized, if one so desires.

Thank you - I will read the manual too. Those sound like they are ideal for adding two parts together.

--

Matthew Jones
Image