• date

    From none) (albert@21:1/5 to All on Fri Oct 20 15:09:43 2023
    Infuriated by the 3 page instructions of the Linux date
    I decided to write my own.
    The worst problem is that there is no canonical date format.
    Look at 'man co' option -d . There is a plethora of options
    to format the date. It is a day's work to find out whether
    they agree.

    --------8< ---------------------------------------
    WANT TIME&DATE .FORMAT
    : doit TIME&DATE "%d /%d /%d -%d :%d :%d" .FORMAT ;
    --------8< ---------------------------------------

    lina -c sdate.frt

    /home/albert/PROJECT/ciforths/ciforth
    ~/PROJECT/ciforths/ciforth: sdate
    2023/10/20-12:56:4~/PROJECT/ciforths/ciforth: dd=`sdate` ~/PROJECT/ciforths/ciforth: echo moments ago the time was $dd
    moments ago the time was 2023/10/20-12:56:15

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to zbigniew2011@gmail.com on Fri Oct 20 16:05:50 2023
    In article <5dd168fa-4461-450d-9cd0-ac1579cea9cfn@googlegroups.com>,
    Zbig <zbigniew2011@gmail.com> wrote:
    Infuriated by the 3 page instructions of the Linux date
    I decided to write my own.
    The worst problem is that there is no canonical date format.

    There are conventions:

    — if you use dots as separator, the date should have DD.MM.YYYY format
    — if slashes — the „American” format MM/DD/YYYY
    — if dashes — the „international” format: YYYY-MM-DD
    — if using Roman digits for the month, the date parts are separated
    by spaces and no leading zero for days is used, like this: 9 X 2023

    One problem may be with British format:: DD/MM/YYYY — they
    also use slashes.

    The problem is that 'date' wants to accomodate all conventions with a
    plethora of options, a lot of more than you mentions here.

    So I think you donot appreciate the problem.
    For an exercise, using linux 'date'
    - find out what options do you need for the American format
    - find out what options do you need for the international format.

    Not even talking about seconds here.

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Zbig@21:1/5 to All on Fri Oct 20 06:19:30 2023
    Infuriated by the 3 page instructions of the Linux date
    I decided to write my own.
    The worst problem is that there is no canonical date format.

    There are conventions:

    — if you use dots as separator, the date should have DD.MM.YYYY format
    — if slashes — the „American” format MM/DD/YYYY
    — if dashes — the „international” format: YYYY-MM-DD
    — if using Roman digits for the month, the date parts are separated
    by spaces and no leading zero for days is used, like this: 9 X 2023

    One problem may be with British format:: DD/MM/YYYY — they
    also use slashes.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Zbig@21:1/5 to All on Fri Oct 20 08:05:32 2023
    I didn't mean Linux; I meant what you can use in ciforth
    having your own 'date' function working just fine. If I had
    to write my own 'date' function I wouldn't care what Linux
    „thinks” about that.
    …or maybe indeed I didn't get in full what you mean.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jan Coombs@21:1/5 to Zbig on Fri Oct 20 18:20:24 2023
    On Fri, 20 Oct 2023 06:19:30 -0700 (PDT)
    Zbig <zbigniew2011@gmail.com> wrote:

    Infuriated by the 3 page instructions of the Linux date
    I decided to write my own.
    The worst problem is that there is no canonical date format.

    There are conventions:

    — if you use dots as separator, the date should have DD.MM.YYYY format
    — if slashes — the „American” format MM/DD/YYYY
    — if dashes — the „international” format: YYYY-MM-DD
    — if using Roman digits for the month, the date parts are separated
    by spaces and no leading zero for days is used, like this: 9 X 2023

    One problem may be with British format:: DD/MM/YYYY — they
    also use slashes.

    YYYY-MM-DD ISO 8601 (EN 28601)

    YYYY-MM-DD_hhmm ?

    Write the whole thing backwards as we do with most other numbers

    Jan Coombs
    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans Bezemer@21:1/5 to none albert on Sun Oct 22 00:17:40 2023
    On Friday, October 20, 2023 at 3:09:53 PM UTC+2, none albert wrote:
    Infuriated by the 3 page instructions of the Linux date
    I decided to write my own.
    The worst problem is that there is no canonical date format.
    Look at 'man co' option -d . There is a plethora of options
    to format the date. It is a day's work to find out whether
    they agree.
    Well, there is ISO 8601and RFC 1123. 4tH (will) support both. For my job I have to do with converting
    data (including dates) all the time. So you will find there is a lot of stuff in 4tH targeted to that one.

    At one time I had to integrate a dozen datasets with slightly different layouts. And the date was a
    complete mess. You can think of a format? Well, somewhere in those twelve sets it was used somewhere.
    So at one time I got REALLY mad and wrote a library that fixed that one permanently. I recently used it
    again when testing an ISO 8601 lib I'd written for work. This is the output:

    $ pp4th -x testdate.4th
    25-MAR-1960 1960-03-25T07:00:00.00
    December 26th 1981 1981-12-26T07:00:00.00
    20031105 2003-11-05T07:00:00.00
    02/12/39 2039-12-02T07:00:00.00
    22. Dezember 1971 1971-12-22T07:00:00.00
    July 4th, 1776 1776-07-04T07:00:00.00
    12 augustus 1925 1925-08-12T07:00:00.00
    14 Julliet 1792 1792-07-14T07:00:00.00
    22161 1960-09-02T07:00:00.00

    It's quite transparent to the user I guess, here is the source of the above program:

    include lib/getdate.4th
    include lib/anscore.4th
    include lib/compare.4th
    include lib/scanskip.4th
    include iso8601.4th

    : splitdate [char] - split number ;
    : tab 9 emit ;

    : makeisodate ( a1 n1 -- a2 n2)
    2dup getdate 2swap 2over compare
    if splitdate >r chop splitdate >r chop number r> r> else 2drop 0 0 0 then
    0 0 7 .datetime0
    ;

    s" 25-MAR-1960" 2dup type tab tab makeisodate type cr
    s" December 26th 1981" 2dup type tab makeisodate type cr
    s" 20031105" 2dup type tab tab makeisodate type cr
    s" 02/12/39" 2dup type tab tab makeisodate type cr
    s" 22. Dezember 1971" 2dup type tab makeisodate type cr
    s" July 4th, 1776" 2dup type tab tab makeisodate type cr
    s" 12 augustus 1925" 2dup type tab makeisodate type cr
    s" 14 Julliet 1792" 2dup type tab tab makeisodate type cr
    s" 22161" 2dup type tab tab tab makeisodate type cr

    If you want to try to port the shebang to ANS, you can find all you need
    right here: https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src/lib/

    Hans Bezemer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)