is a timepoint DSL possible, like: 10:31 instead of "10:29"?

  • Thread starter Dirk Lüsebrink
  • Start date
D

Dirk Lüsebrink

i could not think of any way to include the ':' character in a DSL, so
that i could write:

from 10:30 to 11:30

instead

from "10:30" to "11:30"

I mean, it is not that bad, but still.
dirk

ps.: of course i can always parse it,
 
E

Esad Hajdarevic

I know it is not the same, but you could use .. instead of :, that way
you will get ranges, and you can use Range#min and Range#max to get hour
and minute part.

Esad
 
D

David Vallner

--------------enigA39A1CD69773B1F2F19BDADC
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
i could not think of any way to include the ':' character in a DSL, so =
that i could write:
=20
from 10:30 to 11:30
=20
instead
=20
from "10:30" to "11:30"
=20
I mean, it is not that bad, but still.
dirk
=20
ps.: of course i can always parse it,
=20
=20

I'd just use the 'from 1030 to 1130' notation - hopefully you don't need
to use both time values and integers in the same context.


--------------enigA39A1CD69773B1F2F19BDADC
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFH9asy6MhrS8astoRAsTzAJ9+xPsLo/l1ddodO4tSrNezmHKRfwCeL1v7
cZCshpD7ivnU5uVr6/TKOlY=
=CJ9u
-----END PGP SIGNATURE-----

--------------enigA39A1CD69773B1F2F19BDADC--
 
E

Esad Hajdarevic

David said:
I'd just use the 'from 1030 to 1130' notation - hopefully you don't need
to use both time values and integers in the same context.

why not even more concise: 1030..1130 :)

Esad
 
M

M. Edward (Ed) Borasky

David said:
=20
I'd just use the 'from 1030 to 1130' notation - hopefully you don't nee= d
to use both time values and integers in the same context.
=20

I'd recommend *not* using either integers or floating point (from 10.30
to 11.30) "type puns". The double-quotes are awkward, true, but then
some magic with "strptime" gives you real workable values for time
computations.
 
S

Sammyo

M. Edward (Ed) Borasky said:
I'd recommend *not* using either integers or floating point (from 10.30
to 11.30) "type puns". The double-quotes are awkward, true, but then
some magic with "strptime" gives you real workable values for time
computations.

Not only that, re-think the problem and remove *data* from the code.
Put
it in a config file (where quotes would not be necessary), a database,
or an include file of some kind.
 
S

Scott

Not only that, re-think the problem and remove *data* from the code.
Put
it in a config file (where quotes would not be necessary), a database,
or an include file of some kind.


When writing a DSL in Ruby, often the 'config' file is actual ruby code
(at least in my limited experience), which I'm guessing is probably the
case here. Sometimes its nice to have the full power of Ruby available
in your config/dsl file, rather than having to hook up to a database
just to get config data.

-Scott
 
M

Matthias Reitinger

David said:
I'd just use the 'from 1030 to 1130' notation - hopefully you don't need
to use both time values and integers in the same context.

You could also use 'from 10_30 to 11_30', which is similar in semantics but
a little easier to read.
 
D

Dirk Lüsebrink

thank you all for input on my little question. by now i'm quite sure i
can't trick the ruby parser in accepting 10:30 for anything else than a
syntax error. But i'm quite happy with the propsals, the one i like best
is:

'from 1030 to 1130'

this is reasonable close to what i had in mind(but what is with '0900'
Illegal octal digit?). the basic idea is a console based time accounting
implemented as an internal DSL with:

02.10 10:15-21:30 # a days work
13:45-15:15 # time span: task with begin and end time
0:45 # duration: a task given as duration in hours and
minutes
1.5 # a task given as fractions of hours an minutes

but with the feedback from this list i think i go for an external
DSL(http://www.martinfowler.com/bliki/DomainSpecificLanguage.html).
Regex based parsing should be easy enough. This is because '10_30' and
the octal problems with '0900' might be solvable, but DSL should be for
humans, not for parsers. And that was:

02.10 11:00-
0:30 timepoint DSL # thirty minutes on ruby-forum.

have fun
dirk
 
D

David Vallner

--------------enig0826EC29F1917B4F504042B8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
thank you all for input on my little question. by now i'm quite sure i =
can't trick the ruby parser in accepting 10:30 for anything else than a= =20
syntax error. But i'm quite happy with the propsals, the one i like bes= t=20
is:
=20
'from 1030 to 1130'
=20
this is reasonable close to what i had in mind(but what is with '0900' =
Illegal octal digit?).

As Christian Neukirchen corrected me, you can't use times with leading
zeroes like that. Use only 900 instead of 0900? I still can't think
where that would be ambiguous, provided you always indicate hour+minute
times, never mixing them with only hour and only minute times in a contex=
t.

David Vallner


--------------enig0826EC29F1917B4F504042B8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFIOPhy6MhrS8astoRAp8VAJ4tq3CLyW4xSd295Jq4aSUlq9KgeQCeL8Tq
YPGF70gSxEdXDg0ch6IbbnI=
=5zkQ
-----END PGP SIGNATURE-----

--------------enig0826EC29F1917B4F504042B8--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,214
Messages
2,571,112
Members
47,704
Latest member
DavidSuita

Latest Threads

Top