← Back to team overview

gtg team mailing list archive

[Merge] lp:~nimit-svnit/gtg/bug-1062659 into lp:gtg

 

Nimit Shah has proposed merging lp:~nimit-svnit/gtg/bug-1062659 into lp:gtg.

Requested reviews:
  Gtg developers (gtg)
Related bugs:
  Bug #1062659 in Getting Things GNOME!: "allow locale format for date"
  https://bugs.launchpad.net/gtg/+bug/1062659

For more details, see:
https://code.launchpad.net/~nimit-svnit/gtg/bug-1062659/+merge/134438

Fix for bug #1062659: "Allow locale format of date"
Added additional checks to allow entering date in locale format
-- 
https://code.launchpad.net/~nimit-svnit/gtg/bug-1062659/+merge/134438
Your team Gtg developers is requested to review the proposed merge of lp:~nimit-svnit/gtg/bug-1062659 into lp:gtg.
=== modified file 'CHANGELOG'
--- CHANGELOG	2012-11-11 19:08:06 +0000
+++ CHANGELOG	2012-11-15 11:06:05 +0000
@@ -2,6 +2,7 @@
     * Fix for bug #1024473: Have 'Show Main Window' in notification area, by Antonio Roquentin
     * Fix for bug #1043457: gtcli search returns closed tasks, by Nimit Shah
     * Fix for bug #1073607: "GTG starts after login" doesn't work with an invalid link
+    * Fix for bug #1062659: "Allow locale format of date", by Nimit Shah
 
 2012-11-06 Getting Things GNOME! 0.3
     * Hide tasks with due date someday, #931376

=== modified file 'GTG/core/firstrun_tasks.py'
--- GTG/core/firstrun_tasks.py	2012-07-23 14:40:52 +0000
+++ GTG/core/firstrun_tasks.py	2012-11-15 11:06:05 +0000
@@ -260,7 +260,8 @@
 "defer:date\n"
 "\n"
 "Using this you can apply a due date or a defer date. Dates can be "
-"formated as yyyy-mm-dd (for example 2012-04-01) or yyyymmdd (20120401) "
+"formated as per your locale or yyyy-mm-dd (for example 2012-04-01) or \
+ yyyymmdd (20120401) "
 "or mmdd (0401 - the year being implicitly the current one) or today, "
 "tomorrow or a weekday name (due:monday means due next Monday). Dates "
 "which are added in this way will not appear in the task title.\n"

=== modified file 'GTG/tools/dates.py'
--- GTG/tools/dates.py	2012-05-23 08:55:31 +0000
+++ GTG/tools/dates.py	2012-11-15 11:06:05 +0000
@@ -69,6 +69,8 @@
 
 # ISO 8601 date format
 ISODATE = '%Y-%m-%d'
+#get date format from locale
+locale_format = locale.nl_langinfo(locale.D_FMT)
 
 
 def convert_datetime_to_date(aday):
@@ -84,7 +86,8 @@
     can be constructed with:
       - the fuzzy strings 'now', 'soon', '' (no date, default), or 'someday'
       - a string containing an ISO format date: YYYY-MM-DD, or
-      - a datetime.date or Date instance.
+      - a datetime.date or Date instance, or
+      - a string containing a locale format date.
     """
     _real_date = None
     _fuzzy = None
@@ -104,15 +107,21 @@
             self._fuzzy = value._fuzzy # pylint: disable-msg=W0212
         elif isinstance(value, str) or isinstance(value, unicode):
             try:
-                da_ti = datetime.datetime.strptime(value, ISODATE).date()
+                da_ti = datetime.datetime.strptime(value, locale_format).date()
                 self._real_date = convert_datetime_to_date(da_ti)
             except ValueError:
                 # it must be a fuzzy date
                 try:
-                    value = str(value.lower())
-                    self._parse_init_value(LOOKUP[value])
-                except KeyError:
-                    raise ValueError("Unknown value for date: '%s'" % value)
+                    #allow both locale format and ISO format
+                    da_ti = datetime.datetime.strptime(value, ISODATE).date()
+                    self._real_date = convert_datetime_to_date(da_ti)
+                except ValueError:
+                    # it must be a fuzzy date
+                    try:
+                        value = str(value.lower())
+                        self._parse_init_value(LOOKUP[value])
+                    except KeyError:
+                        raise ValueError("Unknown value for date: '%s'" % value)
         elif isinstance(value, int):
             self._fuzzy = value
         else:

=== modified file 'doc/userdoc/C/gtg-quickadd-dates.page'
--- doc/userdoc/C/gtg-quickadd-dates.page	2012-07-09 15:18:39 +0000
+++ doc/userdoc/C/gtg-quickadd-dates.page	2012-11-15 11:06:05 +0000
@@ -29,7 +29,7 @@
 
     <p><em style="strong">defer:date</em></p>
 
- <p>This way you can apply a due date or a defer date. Dates can be formatted as yyyy-mm-dd (for example 2012-04-01) or yyyymmdd (20120401) or mmdd (0401 - the year being implicitly the current one) or today, tomorrow or a weekday name (due:monday means due next Monday). Dates which are added in this way will not appear in the task title.</p>
+ <p>This way you can apply a due date or a defer date. Dates can be formatted as dates in your locale or yyyy-mm-dd (for example 2012-04-01) or yyyymmdd (20120401) or mmdd (0401 - the year being implicitly the current one) or today, tomorrow or a weekday name (due:monday means due next Monday). Dates which are added in this way will not appear in the task title.</p>
 
     <p>Examples</p>