• What day is tomorrow?

    From Luc@21:1/5 to All on Mon Jan 23 03:37:39 2023
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    Easy. Just check what the month is.

    But then I would need to maintain two lists:
    30-day months and 31-day months.

    And there is always February, of course. So I also have to check
    if it's a leap year.

    Or maybe I can just get today's Epoch, add 86400 seconds and get
    the date corresponding to the resulting Epoch.

    I can do all that by myself, but it definitely sounds like a wheel
    that someone else has invented already.

    Do you know of any? I would like to see what other tools there
    might be in that toolbox.

    I haven't found anything in Tcllib or Tclx.


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Gollwitzer@21:1/5 to All on Mon Jan 23 09:03:55 2023
    Am 23.01.23 um 08:33 schrieb Harald Oehlmann:
    Am 23.01.2023 um 07:37 schrieb Luc:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    clock format [clock add [clock seconds] 1 day] -format %d

    Or use the free-form clock parser:

    clock format [clock scan tomorrow] -format %d

    It also understands "now + 1 day" and similar things

    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Mon Jan 23 09:10:05 2023
    Am 23.01.2023 um 09:03 schrieb Christian Gollwitzer:
    Am 23.01.23 um 08:33 schrieb Harald Oehlmann:
    Am 23.01.2023 um 07:37 schrieb Luc:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    clock format [clock add [clock seconds] 1 day] -format %d

    Or use the free-form clock parser:

    clock format [clock scan tomorrow] -format %d

    It also understands "now + 1 day" and similar things

        Christian

    Wow, I did not know this! You learn each day! Thanks,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Mon Jan 23 08:33:23 2023
    Am 23.01.2023 um 07:37 schrieb Luc:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    Easy. Just check what the month is.

    But then I would need to maintain two lists:
    30-day months and 31-day months.

    And there is always February, of course. So I also have to check
    if it's a leap year.

    Or maybe I can just get today's Epoch, add 86400 seconds and get
    the date corresponding to the resulting Epoch.

    I can do all that by myself, but it definitely sounds like a wheel
    that someone else has invented already.

    Do you know of any? I would like to see what other tools there
    might be in that toolbox.

    I haven't found anything in Tcllib or Tclx.



    clock format [clock add [clock seconds] 1 day] -format %d

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Mon Jan 23 11:00:54 2023
    Am 23.01.2023 um 10:55 schrieb Arjen Markus:
    On Monday, January 23, 2023 at 9:10:07 AM UTC+1, Harald Oehlmann wrote:
    Am 23.01.2023 um 09:03 schrieb Christian Gollwitzer:
    Am 23.01.23 um 08:33 schrieb Harald Oehlmann:
    Am 23.01.2023 um 07:37 schrieb Luc:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    clock format [clock add [clock seconds] 1 day] -format %d

    Or use the free-form clock parser:

    clock format [clock scan tomorrow] -format %d

    It also understands "now + 1 day" and similar things

    Christian
    Wow, I did not know this! You learn each day! Thanks,
    Harald

    You should be a bit careful with that: the free-form parser is a bit quirky, if I understand it correctly. One reason to stay with the more formal arithmetic.

    Regards,

    Arjen

    Yes, and it is depreciated. So, maybe remove it in 9.0 ;-).
    But the solution by Christian is just beautiful !

    Take care,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arjen Markus@21:1/5 to Harald Oehlmann on Mon Jan 23 01:55:44 2023
    On Monday, January 23, 2023 at 9:10:07 AM UTC+1, Harald Oehlmann wrote:
    Am 23.01.2023 um 09:03 schrieb Christian Gollwitzer:
    Am 23.01.23 um 08:33 schrieb Harald Oehlmann:
    Am 23.01.2023 um 07:37 schrieb Luc:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    clock format [clock add [clock seconds] 1 day] -format %d

    Or use the free-form clock parser:

    clock format [clock scan tomorrow] -format %d

    It also understands "now + 1 day" and similar things

    Christian
    Wow, I did not know this! You learn each day! Thanks,
    Harald

    You should be a bit careful with that: the free-form parser is a bit quirky, if I understand it correctly. One reason to stay with the more formal arithmetic.

    Regards,

    Arjen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Mon Jan 23 11:03:09 2023
    * Christian Gollwitzer <[email protected]>
    | Am 23.01.23 um 08:33 schrieb Harald Oehlmann:
    | > Am 23.01.2023 um 07:37 schrieb Luc:
    | >> But if today was the 30th, how would I know what day tomorrow is?
    | >> The 31st or the 1st?
    | >
    | > clock format [clock add [clock seconds] 1 day] -format %d
    | >
    | Or use the free-form clock parser:

    | clock format [clock scan tomorrow] -format %d

    | It also understands "now + 1 day" and similar things

    But be aware of the subtle differences between "24 hours" and "1 day":

    % clock format [clock scan "now"]
    Mon Jan 23 10:53:41 CET 2023

    % clock format [clock scan "now + 24 hours"]
    Tue Jan 24 10:53:41 CET 2023

    % clock format [clock scan "now + 1 day"]
    Tue Jan 24 00:00:00 CET 2023

    % clock format [clock scan tomorrow]
    Tue Jan 24 00:00:00 CET 2023

    % info patchlevel
    8.6.13

    I would have expected that "now + 1 day" produces the same result as
    "now + 24 hours", since the docs state:

    FREE FORM SCAN
    relative time
    A specification relative to the current time. The format is
    number unit. Acceptable units are year, fortnight, month, week,
    day, hour, minute (or min), and second (or sec). The unit can
    be specified as a singular or plural, as in 3 weeks. These mod-
    ifiers may also be specified: tomorrow, yesterday, today, now,
    last, this, next, ago.

    The actual date is calculated according to the following steps.

    First, any absolute date and/or time is processed and converted. Using
    that time as the base, day-of-week specifications are added. Next,
    relative specifications are used.
    !!! If a date or day is specified, and no absolute or relative
    !!! time is given, midnight is used.
    Finally, a correction is applied so that the correct hour of the
    day is produced after allowing for daylight savings time
    differences and the correct date is given when going from the end
    of a long month to a short month.

    (Emphasis by me)

    HTH
    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Heller@21:1/5 to [email protected] on Mon Jan 23 12:44:24 2023
    It is built-in: the clock command will tell you.

    clock add timeVal ?count unit...? ?-option value?


    proc nextdate {month date year} {
    return [clock format [clock add [clock scan \
    [format {%04d-%02d-%02d} $year $month $date] \
    -format {%Y-%m-%d}] 1 day] -format {%m %d %Y}]
    }


    At Mon, 23 Jan 2023 03:37:39 -0300 Luc <[email protected]> wrote:


    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    Easy. Just check what the month is.

    But then I would need to maintain two lists:
    30-day months and 31-day months.

    And there is always February, of course. So I also have to check
    if it's a leap year.

    Or maybe I can just get today's Epoch, add 86400 seconds and get
    the date corresponding to the resulting Epoch.

    I can do all that by myself, but it definitely sounds like a wheel
    that someone else has invented already.

    Do you know of any? I would like to see what other tools there
    might be in that toolbox.

    I haven't found anything in Tcllib or Tclx.



    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    [email protected] -- Webhosting Services

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerald Lester@21:1/5 to Luc on Mon Jan 23 07:26:52 2023
    On 1/23/23 00:37, Luc wrote:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    Easy. Just check what the month is.

    But then I would need to maintain two lists:
    30-day months and 31-day months.

    And there is always February, of course. So I also have to check
    if it's a leap year.

    Or maybe I can just get today's Epoch, add 86400 seconds and get
    the date corresponding to the resulting Epoch.

    I can do all that by myself, but it definitely sounds like a wheel
    that someone else has invented already.

    Do you know of any? I would like to see what other tools there
    might be in that toolbox.

    I haven't found anything in Tcllib or Tclx.

    Read the manual page for the clock command, pay attention to the section
    on the clock add subcommend.

    --
    +----------------------------------------------------------------------+
    | Gerald W. Lester, President, KNG Consulting LLC |
    | Email: [email protected] | +----------------------------------------------------------------------+

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Gollwitzer@21:1/5 to All on Mon Jan 23 20:19:17 2023
    Am 23.01.23 um 11:00 schrieb Harald Oehlmann:
    Am 23.01.2023 um 10:55 schrieb Arjen Markus:
    On Monday, January 23, 2023 at 9:10:07 AM UTC+1, Harald Oehlmann wrote:
    Am 23.01.2023 um 09:03 schrieb Christian Gollwitzer:
    Am 23.01.23 um 08:33 schrieb Harald Oehlmann:
    Am 23.01.2023 um 07:37 schrieb Luc:
    Today is 23 so tomorrow is 24, no problem.

    But if today was the 30th, how would I know what day tomorrow is?
    The 31st or the 1st?

    clock format [clock add [clock seconds] 1 day] -format %d

    Or use the free-form clock parser:

    clock format [clock scan tomorrow] -format %d

    It also understands "now + 1 day" and similar things

         Christian
    Wow, I did not know this! You learn each day! Thanks,
    Harald

    You should be a bit careful with that: the free-form parser is a bit
    quirky, if I understand it correctly. One reason to stay with the more
    formal arithmetic.

    Regards,

    Arjen

    Yes, and it is depreciated. So, maybe remove it in 9.0 ;-).
    But the solution by Christian is just beautiful !

    I know it is deprecated and I think it is a mistake to completely take
    it away, since it has these nice features. If it is moved away, I think
    it should go into something like
    clock scan -format free "tomorrow"
    or "clock guess tomorrow" or maybe into tcllib.

    Christian

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