[web2py] Re: date format of date picker

2015-08-01 Thread Annet
What about the validator:

isdate = dict(type='date', requires=IS_DATE(format='%d-%m-%Y', 
error_message='Formaat komt niet overeen met dd-mm-'),
  represent=lambda v: v.strftime('%d/%m/%Y') if v else '')


Kind regards,

Annet

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Date format and date picker

2014-03-05 Thread mcamel
Very strange. This works for me at Chromium Version 32.0.1700.107 Ubuntu 
12.04:

def test_date():
T.force('it')

db = DAL('sqlite:memory:')
db.define_table('test', Field('d', 'date'))

form = SQLFORM(db.test)
form.validate()

return dict(form=form)

At it.py (you can also translate 'enter date as %(format)s'):

'%Y-%m-%d': '%d/%m/%Y',

If i mispelled date intentionally i get:
enter date as 28/08/1963

Does this code work for you?.

By the way i've noticed you've mispelled the format in your post (one 
percent symbol is missing at %d/m/%Y). Check it at your languege file just 
in case...

Regards.


El martes, 4 de marzo de 2014 22:50:17 UTC+1, Gael Princivalle escribió:

 Ok so like that:
 Field('concert_date', type='date', requires = IS_DATE(format='%Y-%m-%d'))
 And on Chrome problem still the same.
 I think the problem is more global about language detection with Chrome.

 If I use web2py on Firefox I've got no problems.

 On Chrome it's a disaster. For example when I go on the welcome app, it's 
 always in English, not in Italian.

 Here is my routes.py :
 routers = dict(
  BASE = dict(
  domains = { 
'domain1.it' : 'myapp1',
'domain2.it':  'myapp2',
},
  default_application='welcome', 
 ),
  myapp1 = dict(languages=['en', 'it'], default_language='it'),
  myapp2 = dict(languages=['en', 'it'], default_language='it'),
 )

 Do you know what's the problem ?

 Regards

 Il giorno martedì 4 marzo 2014 22:26:37 UTC+1, Anthony ha scritto:

 Here is my field in db.py:
 Field('concert_date', type='date', requires = IS_DATE(format=T(
 '%Y-%m-%d')))


 Do not wrap the format argument to IS_DATE() in T() -- it will be 
 translated automatically.

 Also, if desired, note that you can alter the date format for the 
 Javascript widget universally here: 
 https://github.com/web2py/web2py/blob/master/applications/welcome/views/web2py_ajax.html#L5
 .

 Anthony



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Date format and date picker

2014-03-05 Thread Gael Princivalle
Sorry for that. My language Chrome setting was with English as first. Now
with Italian that's ok.


2014-03-05 12:08 GMT+01:00 mcamel mca...@gmail.com:

 Very strange. This works for me at Chromium Version 32.0.1700.107 Ubuntu
 12.04:

 def test_date():
 T.force('it')

 db = DAL('sqlite:memory:')
 db.define_table('test', Field('d', 'date'))

 form = SQLFORM(db.test)
 form.validate()

 return dict(form=form)

 At it.py (you can also translate 'enter date as %(format)s'):

 '%Y-%m-%d': '%d/%m/%Y',

 If i mispelled date intentionally i get:
 enter date as 28/08/1963

 Does this code work for you?.

 By the way i've noticed you've mispelled the format in your post (one
 percent symbol is missing at %d/m/%Y). Check it at your languege file just
 in case...

 Regards.


 El martes, 4 de marzo de 2014 22:50:17 UTC+1, Gael Princivalle escribió:

 Ok so like that:
 Field('concert_date', type='date', requires = IS_DATE(format='%Y-%m-%d'))
 And on Chrome problem still the same.
 I think the problem is more global about language detection with Chrome.

 If I use web2py on Firefox I've got no problems.

 On Chrome it's a disaster. For example when I go on the welcome app, it's
 always in English, not in Italian.

 Here is my routes.py :
 routers = dict(
  BASE = dict(
  domains = {
'domain1.it' : 'myapp1',
'domain2.it':  'myapp2',
},
  default_application='welcome',
 ),
  myapp1 = dict(languages=['en', 'it'], default_language='it'),
  myapp2 = dict(languages=['en', 'it'], default_language='it'),
 )

 Do you know what's the problem ?

 Regards

 Il giorno martedì 4 marzo 2014 22:26:37 UTC+1, Anthony ha scritto:

 Here is my field in db.py:
 Field('concert_date', type='date', requires = IS_DATE(format=T(
 '%Y-%m-%d')))


 Do not wrap the format argument to IS_DATE() in T() -- it will be
 translated automatically.

 Also, if desired, note that you can alter the date format for the
 Javascript widget universally here: https://github.com/
 web2py/web2py/blob/master/applications/welcome/views/web2py_ajax.html#L5
 .

 Anthony

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/VzOWqWhWKWQ/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Date format and date picker

2014-03-04 Thread Gael Princivalle
Yes I have it in my it.py language file.

But when I choose in the datepicker a date in my Italian page, date picker 
give me the date in '%d/%m/%Y', but the field validation still in US format:
enter date as 1963-08-28

Here is my field in db.py:
Field('concert_date', type='date', requires = IS_DATE(format=T('%Y-%m-%d')))

Perhaps I have to do something more in my grid ?
def edit_concerts():
query = db.concerts
grid = SQLFORM.grid(query=query, csv=False, links_in_grid=False, links=
None, searchable=True, editable=True, deletable=False, create=True, details=
True, orderby=db.concerts.concert_date)
return dict(grid = grid)

Thanks.

Il giorno lunedì 3 marzo 2014 13:25:33 UTC+1, mcamel ha scritto:

 I'm not sure to understand your problem, but just in case it helps: have 
 you tried to use this in your language file:

 '%Y-%m-%d': '%d/%m/%Y',

 Default date validator will do inner convertions between both formats, so 
 you'll have no problems with DAL and database backend.

 Regards.


 El sábado, 1 de marzo de 2014 17:49:36 UTC+1, Gael Princivalle escribió:

 Hello all.

 I'm a little bit disappointed by the date format and datepicker.

 First my field was like that:

 Field('concert_date', type='date'),

 On Firefox no problem. It give me automaticly the possibility to put in 
 the field the local %d/m/%Y format, and this format was accepted by the 
 DAL. When I open this row, date is ok.

 As Firefox 27 for Windows is incredibly slow, I'm still using Chrome from 
 this morning.

 With Chrome if I open again this row date it's ok but with the US format 
 %Y-%m-%d. For example 12/03/2014 change in 2014-03-12. It's the default SQL 
 Lite date format, why not.

 But if I open datepicker, it shows me on the calendar September 4 2017.

 What I want to do is:
 Choose with datepicker the date format always like %d/m/%Y.
 Saving the date in DAL as US format %Y-%m-%d
 Showing in the row the date format as local (%Y-%m-%d or %d/m/%Y)

 Can you help me ?

 Thanks, regards.





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Date format and date picker

2014-03-04 Thread Anthony


 Here is my field in db.py:
 Field('concert_date', type='date', requires = IS_DATE(format=T('%Y-%m-%d'
 )))


Do not wrap the format argument to IS_DATE() in T() -- it will be 
translated automatically.

Also, if desired, note that you can alter the date format for the 
Javascript widget universally 
here: 
https://github.com/web2py/web2py/blob/master/applications/welcome/views/web2py_ajax.html#L5.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Date format and date picker

2014-03-04 Thread Gael Princivalle
Ok so like that:
Field('concert_date', type='date', requires = IS_DATE(format='%Y-%m-%d'))
And on Chrome problem still the same.
I think the problem is more global about language detection with Chrome.

If I use web2py on Firefox I've got no problems.

On Chrome it's a disaster. For example when I go on the welcome app, it's 
always in English, not in Italian.

Here is my routes.py :
routers = dict(
 BASE = dict(
 domains = { 
   'domain1.it' : 'myapp1',
   'domain2.it':  'myapp2',
   },
 default_application='welcome', 
),
 myapp1 = dict(languages=['en', 'it'], default_language='it'),
 myapp2 = dict(languages=['en', 'it'], default_language='it'),
)

Do you know what's the problem ?

Regards

Il giorno martedì 4 marzo 2014 22:26:37 UTC+1, Anthony ha scritto:

 Here is my field in db.py:
 Field('concert_date', type='date', requires = IS_DATE(format=T('%Y-%m-%d'
 )))


 Do not wrap the format argument to IS_DATE() in T() -- it will be 
 translated automatically.

 Also, if desired, note that you can alter the date format for the 
 Javascript widget universally here: 
 https://github.com/web2py/web2py/blob/master/applications/welcome/views/web2py_ajax.html#L5
 .

 Anthony


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Date format and date picker

2014-03-03 Thread mcamel
I'm not sure to understand your problem, but just in case it helps: have 
you tried to use this in your language file:

'%Y-%m-%d': '%d/%m/%Y',

Default date validator will do inner convertions between both formats, so 
you'll have no problems with DAL and database backend.

Regards.


El sábado, 1 de marzo de 2014 17:49:36 UTC+1, Gael Princivalle escribió:

 Hello all.

 I'm a little bit disappointed by the date format and datepicker.

 First my field was like that:

 Field('concert_date', type='date'),

 On Firefox no problem. It give me automaticly the possibility to put in 
 the field the local %d/m/%Y format, and this format was accepted by the 
 DAL. When I open this row, date is ok.

 As Firefox 27 for Windows is incredibly slow, I'm still using Chrome from 
 this morning.

 With Chrome if I open again this row date it's ok but with the US format 
 %Y-%m-%d. For example 12/03/2014 change in 2014-03-12. It's the default SQL 
 Lite date format, why not.

 But if I open datepicker, it shows me on the calendar September 4 2017.

 What I want to do is:
 Choose with datepicker the date format always like %d/m/%Y.
 Saving the date in DAL as US format %Y-%m-%d
 Showing in the row the date format as local (%Y-%m-%d or %d/m/%Y)

 Can you help me ?

 Thanks, regards.





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Date format and date picker

2014-03-01 Thread Tim Richardson
I try to consider that a field defined as Date is a Date in the python 
sense, not a string representation. In some backends it may be a stored as 
a string, but I consider that the private business of the database. The DAL 
gives back a Date. 
(If it was stored as a string I would hope that it was ISO format, 
-MM-DD). 

But really, it's a Date. You can convert Dates to strings with the Python 
dateutil library. 

As for datepicker, this thread may help (or search for datepicker localise):

https://groups.google.com/forum/#!searchin/web2py/datepicker$20date$20format/web2py/pvAbhedCPIg/wpj-u_22xG4J







On Sunday, 2 March 2014 03:49:36 UTC+11, Gael Princivalle wrote:

 Hello all.

 I'm a little bit disappointed by the date format and datepicker.

 First my field was like that:

 Field('concert_date', type='date'),

 On Firefox no problem. It give me automaticly the possibility to put in 
 the field the local %d/m/%Y format, and this format was accepted by the 
 DAL. When I open this row, date is ok.

 As Firefox 27 for Windows is incredibly slow, I'm still using Chrome from 
 this morning.

 With Chrome if I open again this row date it's ok but with the US format 
 %Y-%m-%d. For example 12/03/2014 change in 2014-03-12. It's the default SQL 
 Lite date format, why not.

 But if I open datepicker, it shows me on the calendar September 4 2017.

 What I want to do is:
 Choose with datepicker the date format always like %d/m/%Y.
 Saving the date in DAL as US format %Y-%m-%d
 Showing in the row the date format as local (%Y-%m-%d or %d/m/%Y)

 Can you help me ?

 Thanks, regards.





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.