Regarding over engineering, I think that the composability of factor's
libraries make the object allocations worth it. See
https://docs.factorcode.org/content/article-cookbook-philosophy.html "Object
allocation is very cheap. Don't be afraid to create tuples [...]".
However, the restriction to timestamps with TYPED: was added exactly (see
b059ade5eda) to prevent using those words on durations. That's because
their internal state doesn't behave like timestamps and you must call the
duration>XX words instead of accessing the slots directly:
3600 seconds (timestamp>hms)
00:00:3600
3600 seconds duration>hm
"01:00"
It looks like we could have more duration>XXX formatting words ?
Also, in calendar.format, write-gmt-offset and write-rfc3339-gmt-offset
access the slots directly. So now we have:
2010 10 10 10 10 10 1 hours <timestamp> timestamp>rfc822
"Sun, 10 Oct 2010 10:10:10 +0100"
2010 10 10 10 10 10 3600 seconds <timestamp> timestamp>rfc822 .
"Sun, 10 Oct 2010 10:10:10 +0000"
Bug of feature ? :)
Jon
On Wed, Jul 20, 2016 at 10:07 AM, Alexander Ilin <ajs...@yandex.ru> wrote:
> Hello!
>
> On the second thought, that may be overengineering a bit. After all, do
> I need to create a duration object and a string stream (within a namespace
> to override output-stream) just to do some string manipulation? Here's a
> solution with smaller overhead :
>
> : seconds>hms ( n -- str )
> 60 /mod round [ 60 /mod round ] dip 3array [ pad-00 ] map ":" join ;
>
> 20.07.2016, 10:44, "Alexander Ilin" <ajs...@yandex.ru>:
> > Hello!
> >
> > I'm measuring some processes, which take anywhere from seconds to
> hours to run.
> > I record the number of seconds in a DB for future reference.
> > When presenting the data to the user (myself) I want to see a hh:mm:ss
> string instead of thousands of seconds.
> >
> > Is there a way to format a duration tuple in such a way? The closest
> thing I found is timestamp>hms, which does exactly what I want, but it is
> TYPED:, and only accepts timestamps. Can I add the following word to the
> calendar.format, or is there a better way?
> >
> > TYPED: duration>hms ( duration: duration -- str )
> > [ (timestamp>hms) ] with-string-writer ;
> >
> > ---=====---
> > Александр
> >
> >
> ------------------------------------------------------------------------------
> > What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> > patterns at an interface-level. Reveals which users, apps, and protocols
> are
> > consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> > J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> > reports.http://sdm.link/zohodev2dev
> > _______________________________________________
> > Factor-talk mailing list
> > Factor-talk@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> ---=====---
> Александр
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk