1. datetime functions
- Posted by Jeremy Cowgar <jeremy at cow?ar.com> Apr 25, 2008
- 642 views
Ok, Since there was much discussion about datetime, I'm starting this thread. In SVN are the new datetime functions. I have remove datetime_compare, datetime_add_days, datetime_add_seconds. I have removed datetime_ prefix. I have added add and subtract functions that work on intervals. SECONDS, MINUTES, HOURS, DAYS, WEEKS are implemented. MONTHS and YEARS exist but do nothing right now
include datetime.e as d datetime dt1, dt2 dt1 = d:now() dt2 = d:add(dt1, 12, DAYS) dt2 = d:subtract(dt1, 15, WEEKS) --- etc...
Look good? -- Jeremy Cowgar http://jeremy.cowgar.com
2. Re: datetime functions
- Posted by ChrisBurch2 <crylex at freeuk.co??k> Apr 25, 2008
- 604 views
Hi Phew, having difficulty keeping up. Can I take a date string, (24/05/2008), add 47 days, and get a date string back? Note the UK localisation! Chris
3. Re: datetime functions
- Posted by Pete Stoner <stoner.pete at gmail.?o?> Apr 25, 2008
- 621 views
Jeremy Cowgar wrote: > > Ok, Since there was much discussion about datetime, I'm starting this thread. > > In SVN are the new datetime functions. I have remove datetime_compare, > datetime_add_days, > datetime_add_seconds. I have removed datetime_ prefix. I have added add and > subtract functions that work on intervals. SECONDS, MINUTES, HOURS, DAYS, > WEEKS > are implemented. MONTHS and YEARS exist but do nothing right now > > }}} <eucode> > include datetime.e as d > datetime dt1, dt2 > dt1 = d:now() > dt2 = d:add(dt1, 12, DAYS) > dt2 = d:subtract(dt1, 15, WEEKS) > --- etc... > </eucode> {{{ > > Look good? I don't want to reopen a can of worms but I've been following the discussion and must have missed where it was agreed to drop the prefix. It just seems to me that add() is rather ambiguous, there is already the precedent set in EU for the edb commands of having a db_ prefix, so for the datetime functions to look integrated with the core commands I feel it should have a dt_ prefix PeteS
4. Re: datetime functions
- Posted by Jeremy Cowgar <jeremy at cowg?r?com> Apr 25, 2008
- 615 views
ChrisBurch2 wrote: > > Hi > > Phew, having difficulty keeping up. > > Can I take a date string, (24/05/2008), add 47 days, and get a date string > back? > > Note the UK localisation! > Chris, There are two skeleton functions (no code yet). format and parse. You will have to do something like:
datetime dt dt = d:parse(date, "%d/%m/%Y") dt = d:add(dt, 47, DAYS) puts(1, d:format(dt, "%d/%m/%Y")
Of course, you could create constants for the date/time format. -- Jeremy Cowgar http://jeremy.cowgar.com
5. Re: datetime functions
- Posted by Jeremy Cowgar <jeremy at ?owgar?com> Apr 25, 2008
- 620 views
Pete Stoner wrote: > > I don't want to reopen a can of worms but I've been following the discussion > and must have missed where it was agreed to drop the prefix. It just seems to > me that add() is rather ambiguous, there is already the precedent set in EU > for the edb commands of having a db_ prefix, so for the datetime functions to > look integrated with the core commands I feel it should have a dt_ prefix > I don't think the functions will be ambiguous, as you can specify a namespace.
include datetime.e as dt datetime d d = dt:now() -- or include datetime.e as datetime datetime d d = datetime:now()
So, now the users can have as short or long prefix as they want. As for the precedence, only database.e is using prefixes vs. the hundred other functions? Now, I am having a bit of a problem w/totally no prefix, please see my next post... about documentation. -- Jeremy Cowgar http://jeremy.cowgar.com
6. Re: datetime functions
- Posted by Pete Stoner <stoner.pete at gmail.co?> Apr 25, 2008
- 623 views
Jeremy Cowgar wrote: > > Pete Stoner wrote: > > > > I don't want to reopen a can of worms but I've been following the discussion > > and must have missed where it was agreed to drop the prefix. It just seems > > to > > me that add() is rather ambiguous, there is already the precedent set in EU > > for the edb commands of having a db_ prefix, so for the datetime functions > > to > > look integrated with the core commands I feel it should have a dt_ prefix > > > > I don't think the functions will be ambiguous, as you can specify a namespace. > > }}} <eucode> > include datetime.e as dt > datetime d > d = dt:now() > > -- or > > include datetime.e as datetime > datetime d > d = datetime:now() > </eucode> {{{ > > So, now the users can have as short or long prefix as they want. As for the > precedence, only database.e is using prefixes vs. the hundred other functions? > I know you can use a namespace, indeed for the code to be clear you would have to and to be pedantic it actually amounts to more typing dt: is same as dt_ but you also need the include as.. The general difference between the Database set of commands and all the others is that they are just that, a set of related commands, so the prefix makes sense. So since the dateTime routines are equally a set I stick to my dt_ suggestion. It would also reduce the risk of namespace clashes without having to remember to do the "include as" (which if you are lazy like I am you may well skip). Don't get me wrong, I applaud your work on this, too many times in the past work on similar standard additions has been started and got bogged down for one reason or another, so this work is long overdue. PeteS
7. Re: datetime functions
- Posted by Jeremy Cowgar <jeremy at ?owgar.co?> Apr 25, 2008
- 606 views
Pete Stoner wrote: > > The general difference between the Database set of commands and all the others > is that they are just that, a set of related commands, so the prefix makes > sense. Pete, you have a very good point. Also, task has a prefix, I forgot about that. Maybe the simplest and correct solution to both my problems is to prefix with dt_ as you have suggested. -- Jeremy Cowgar http://jeremy.cowgar.com
8. Re: datetime functions
- Posted by Matt Lewis <matthewwalkerlewis at g?ai?.com> Apr 25, 2008
- 626 views
Pete Stoner wrote: > > I don't want to reopen a can of worms but I've been following the discussion > and must have missed where it was agreed to drop the prefix. It just seems to > me that add() is rather ambiguous, there is already the precedent set in EU > for the edb commands of having a db_ prefix, so for the datetime functions to > look integrated with the core commands I feel it should have a dt_ prefix database.e is fairly old (at least with respect to namespaces in euphoria). In the next version, they're even more powerful, and a lot of work has been done to make name resolution work better. Prefixing adds a lot of verbosity that isn't always needed. Matt
9. Re: datetime functions
- Posted by yuku <yuku at ikitek.?om> Apr 25, 2008
- 619 views
Jeremy Cowgar wrote: > > Pete Stoner wrote: > > > > > The general difference between the Database set of commands and all the > > others > > is that they are just that, a set of related commands, so the prefix makes > > sense. > > Pete, you have a very good point. Also, task has a prefix, I forgot about > that. > Maybe the simplest and correct solution to both my problems is to prefix with > dt_ as you have suggested. For me, I prefer no prefix IF the new namespace design in 3.2 really solves the namespace problem. The obstacle now is that I cannot build 3.2 due to some errors that I mentioned in the "3.2/4.0 build" subject. I am quite sure majority of the people here do not or cannot build the exe from the source. It is very unclear how to build it correctly. Therefore, can someone help build it and upload it (maybe to the Recent User Contribution page) so that we ALL can try the new namespace design and also {peek,poke}{2*,_string} functions.
10. Re: datetime functions
- Posted by CChris <christian.cuvier at ag?iculture.gouv?fr> Apr 25, 2008
- 618 views
yuku wrote: > > Jeremy Cowgar wrote: > > > > Pete Stoner wrote: > > > > > > > > The general difference between the Database set of commands and all the > > > others > > > is that they are just that, a set of related commands, so the prefix makes > > > sense. > > > > Pete, you have a very good point. Also, task has a prefix, I forgot about > > that. > > Maybe the simplest and correct solution to both my problems is to prefix > > with > > dt_ as you have suggested. > > > For me, I prefer no prefix IF the new namespace design in 3.2 really solves > the > namespace problem. The obstacle now is that I cannot build 3.2 due to some > errors > that I mentioned in the "3.2/4.0 build" subject. > > I am quite sure majority of the people here do not or cannot build the > exe from the source. It is very unclear how to build it correctly. > > Therefore, can someone help build it and upload it (maybe to the Recent User > Contribution page) > so that we ALL can try the new namespace design and also > {peek,poke}{2*,_string} > functions. Did you check EuForum prior about these compile errors? Look for "matherr", I'm sure it came up in the compile errors. Then you'll find out that the compile flags need -dEOW added so that OpenWatcom v1.x can compile quietly. RDS still uses 10.6, so the makefile doesn't contain this flag. CChris