Hi Przemek,

Many thanks for the detailed reply.

Since it appears that the 2 most important differences you described have
now been addresed, I vote for complete synch, and would greatly appreciate
your help in achieving a full synch with Harbour's TIESTAMP support.

Please let us know which code if any will require addtional work.

Walter, Andi, ..., any input?

Ron
On Nov 11, 2011 8:00 PM, "Przemysław Czerpak" <dru...@poczta.onet.pl> wrote:

> On Thu, 10 Nov 2011, Ron Pinkas wrote:
>
> Hi Ron,
>
> > Could you please help us review and consider synch issues of
> > DATETIME support between Harboiur and xHarbour?
>
> There were some deeper modifications in this are in xHarbour
> recently. I'll look at it. Initial datetime implementation in
> xHarbour was really interesting and good peace of code but it
> introduce some incompatibilities to Clipper and needed some
> minor code cleanup. Anyhow it was not precisely defined how
> it should work. Now it's the most important problem in keeping
> this code alive. It's hard to cleanup anomalies when programmer
> does not know expected behavior. If you agree then I can add
> support for Harbour like datetime arithmetics to HVM code and
> update some vital part of core code. Anyhow it's not fully
> compastible with current xHarbour behavior. There were two most
> importatn differences betwen Harbour and xHarbour:
> 1. initial date value which can be seen in this code:
>      proc main()
>         set date format to "yyyy/mm/dd"
>         ? {^ 02:00 }
>      return
>
>   Harbour shows:
>          /  /   02:00:00.000
>   xHarbour:
>      1899/12/30 02:00:00.000
>   This difference is important in code exchanging data with OLE
>   servers so OLE interface has to be updated to keep it.
>
> 2. Separate type for date values when non integer number is
>   aded to date item.
>   As I can see current xHarbour SVN works like Harbour so this
>   difference does not longer exists but I'm not sure if other
>   code which needed such behavior had been updated.
>
> I can add Harbour like TIMESTAMP values and update most important
> parts of core non HVM code but I'm afraid I cannot make it for whole
> xHarbour code. I hope that other developers can adopt their code if
> necessary. As I can see in some places there is also code borrowed
> from Harbour which will begin to work correctly when I'll update HVM
> anyhow I cannot promise that I'll update whole xHarbour code to fully
> respect new timestamp values.
> Below I'm attaching small text I created to describe differences
> between Harbour and xHarbour. Recent modifications in xHarbour HVM
> changed xHarbour behavior so now it does not well describes it.
> Anyhow it's still good description of TIMESTAMP values in Harbour
> If you can accept it then I'll commit modification which introduce
> it to xHarbour.
>
> best regards,
> Przemek
>
>
>
>
> ###    DATETIME/TIMESTAMP VALUES    ###
> =======================================
> Both compilers support DATETIME/TIMESTAMP values though they use different
> implementation.
>
> In Harbour it's new type TIMESTAMP for which VALTYPE() function returns
> "T". It has its own HVM arithmetic similar to the one used by DATE type
> but not exactly the same. The difference (-) between two TIMESTAMP values
> is represented as number where integer part is number of days and
> fractional
> part is time in given day. Non-exact comparison (=, >, <, >=, <=) for
> TIMESTAMP and DATA value assumes that both values are equal if the date
> part is the same. Such semantic is also respected by native RDDs when
> mixed DATE and TIMESTAMP values are used in indexes, seeks, scopes, etc.
> When number is added to DATE type then like in Clipper only integer part
> increase (decrease) DATE value but when it's added to TIMESTAMP value then
> fractional part is also significant. When TIMESTAMP value is added to DATE
> value then as result new TIMESTAMP value is calculated. Here is detail
> information about relational and arithmetic operators in Harbour.
> Timestamp values in relational operators <, <=, >, >=, =, ==
>      - When two timestamp values are compared then VM compares date and
>        time parts in both values.
>      - When date and timestamp values are used in <, <=, >, >=, =
>        operations then VM compares only date part in both values.
>      - When date and timestamp values are used in == operation then VM
>        compares date part in both values and then check if time part
>        of timestamp value is 0.
> Timestamp values in + and - math operations:
>      <t> + <t> => <t>
>      <t> - <t> => <n>
>      <t> + <n> => <t>
>      <n> + <t> => <t>
>      <t> - <n> => <t>
>      <d> + <t> => <t>
>      <t> + <d> => <t>
>      <d> - <t> => <n>
>      <t> - <d> => <n>
>   when number is result or argument of timestamp operation then its integer
>   part is a number of days and fractional part represents time in day.
>
> In xHarbour DATE type was extended to hold information about time. Clipper
> compatible DATE arithmetic in HVM was modified to respect fractional part
> in numbers which was used for time part.
> The xHarbour DATETIME implementation introduces incompatibilities to
> Clipper
> (f.e. compare Clipper and xHarbour results in code like: '? date() + 1.125'
> so in some cases existing Clipper code has to be carefully adopted to work
> correctly with xHarbour but it's fully functional solution though it needs
> some minor fixes in conversions between datetime values and numbers.
>
> The difference between Harbour and xHarbour can be seen in this code:
>      proc main()
>         local dVal, tVal
>         dVal := date()
>         tVal := dVal + {^ 02:00 }  // {^ 02:00 } timestamp
>                                    // constant, see below
>         ? valtype(dVal), valtype(tVal)
>         ? dVal; ? tVal
>         dVal += 1.125  // In Clipper and Harbour it increases
>                        // date value by 1
>         tVal += 1.25   // it it increases timestamp value by 1 day
>                        // and 6 hours
>         ? dVal; ? tVal
>         ? dVal = tVal  // In Harbour .T. because date part is the same
>         ? date() + 0.25, date() + 0.001 == date()
>      return
> Harbour shows:
>      D T
>      05/20/09
>      05/20/09 02:00:00.000
>      05/21/09
>      05/21/09 08:00:00.000
>      .T.
>      05/20/09 .T.
>
> and xHarbour shows:
>      D D
>      05/20/09
>      06/25/21 02:00:00.00
>      05/21/09 03:00:00.00
>      06/26/21 08:00:00.00
>      .F.
>      05/20/09 06:00:00.00 .F.
>
> Recently to xHarbour "T" type was introduced with some of Harbour TIMESTAMP
> code in RDD but VM was not modified to follow Harbour/RDD modifications.
> So now some parts of xHarbour are not synced and I cannot say what is the
> goal of DATETIME values and their arithmetic in xHarbour VM for the future.
>
>
>
> ###    LITERAL DATE AND TIMESTAMP VALUES    ###
> ===============================================
> Both compilers tries to support VFP like datetime constant values
> in the following format:
>      { ^ [ YYYY-MM-DD [,] ] [ HH[:MM[:SS][.FFF]] [AM|PM] ] }
> In Harbour and VFP the following characters can be used as date delimiters:
> "-", "/" and "."
> xHarbour supports only "/" as date delimiter.
> There is no limit on number of digits in YYYY, MM, DD, HH, MM, SS, FFF
> parts. Important is only their value. This is the format in semi PP
> notation:
>      { ^ <YEAR> <sep:/-> <MONTH> <sep:/-> <DAY> [[<sep2:,>]
>        [ <HOUR> [ : <MIN> [ : <SEC> [ . <FRAQ> ] ] ] [AM|PP] ] }
> NOTE: there is one important difference between Harbour and VFP/xHarbour in
> decoding above format. In VFP and xHarbour when date part is missed then
> it's set by default to: 1899-12-30 so this code:
>      { ^ 12:00 }
> gives the same results as:
>      { ^ 1899/12/30 12:00 }
> Harbour does not set any default date value when timestamp constant
> contains
> only time part.
> Harbour supports VFP syntax only in Compiler. It's not supported in
> macrocompiler and it can be disabled in the future so it's not suggested
> to use with Harbour programs.
>
> Only Harbour supports date constant (in compiler and macrocompiler) in the
> form d"YYYY-MM-DD" f.e.:
>      d"2009-05-20"
> Also delimiter "/" or "." can be used instead of "-".
>
> Only Harbour supports timestamp constant (in compiler and macrocompiler)
> in the form t"YYYY-MM-DD HH:MM:SS.fff"
> The exact accepted timestamp pattern is is:
>      YYYY-MM-DD [H[H][:M[M][:S[S][.f[f[f[f]]]]]]] [PM|AM]
> f.e.:
>      tValue := t"2009-03-21 5:31:45.437 PM"
> or:
>      YYYY-MM-DDT[H[H][:M[M][:S[S][.f[f[f[f]]]]]]] [PM|AM]
> with literal "T" as date and time part delimiters (XML timestamp format),
> f.e.:
>      tValue := t"2009-03-21T17:31:45.437"
> The following characters can be used as date delimiters: "-", "/", "."
> if PM or AM is used HH is in range < 1 : 12 > otherwise in range < 0 : 23 >
>
> Harbour compiler and macrocompiler support also date constants in the
> form 0dYYYYMMDD f.e.:
>      0d20090520.
>
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to