Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: dxf Newsgroups: comp.lang.forth Subject: Re: Parsing timestamps? Date: Tue, 8 Oct 2024 18:33:40 +1100 Organization: i2pn2 (i2pn.org) Message-ID: <43a038b332e65d36ee48bb8abdbb9d48577b12c4@i2pn2.org> References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> <8650bd010df25e0833e658b7b54995b4ca62fec8@i2pn2.org> <927ca1c2b969054aafdcd77657ab096b10eded5d@i2pn2.org> <7c888269275dcb35f26651b0a28eca21@www.novabbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 8 Oct 2024 07:33:41 -0000 (UTC) Injection-Info: i2pn2.org; logging-data="1074073"; mail-complaints-to="usenet@i2pn2.org"; posting-account="XPw7UV90Iy7EOhY4YuUXhpdoEf5Vz7K+BsxA/Cx8bVc"; User-Agent: Mozilla Thunderbird X-Spam-Checker-Version: SpamAssassin 4.0.0 Content-Language: en-GB In-Reply-To: <7c888269275dcb35f26651b0a28eca21@www.novabbs.com> Bytes: 2241 Lines: 30 On 8/10/2024 5:08 pm, Ahmed wrote: > On Tue, 8 Oct 2024 3:07:31 +0000, dxf wrote: > >> Not bad.  Here's a translation.  Hopefully it's equivalent (?) >> >> : split ( a u c -- a2 u2 a3 u3 ) >>   >r 2dup r> scan 2swap 2 pick - ; >> >> : number ( a u -- u )  0 0 2swap >number 2drop ; >> >> : xx. ( u -- )  0 <# bl hold # # #> type ; >> : tab3. ( h m s -- )  3 spaces ( tab)  rot xx. swap xx. xx. ; >> >> : ts_elms ( a u -- h m s ) >>   2>r  0 0 0  2r>  begin >>     [char] : skip  [char] : split  dup 0> while >>     number drop  5 roll drop -rot >>   repeat 2drop 2drop ; >> >> s" 25"      ts_elms  tab3.    00 00 25  ok >> s" 10:25"   ts_elms  tab3.    00 10 25  ok >> s" 2:10:25" ts_elms  tab3.    02 10 25  ok > > I know you don't care about this case, but: > s" 1:1:"      ts_elms  tab3.        00 01 01  ok > It should be 01 01 00 Yes. It's an unlikely scenario. For a format that begins with seconds that field must be filled first. Only when it overflows will a separator and minutes field be added.