Skip to content

Commit

Permalink
format date in cvs
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Nov 15, 2024
1 parent dad6c37 commit ff87ad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_fields_labels(self, item):

def format_date(self, value):
return api.portal.get_localized_time(value)

def get_data(self):
store = getMultiAdapter((self.context, self.request), IFormDataStore)
sbuf = StringIO()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def test_export_csv(self):
"field_id": "when",
"field_type": "date",
},

],
},
}
Expand Down Expand Up @@ -258,7 +257,9 @@ def test_export_csv(self):
self.assertEqual(data[0], ["Message", "Name", "When", "date"])
sorted_data = sorted(data[1:])
self.assertEqual(sorted_data[0][:-1], ["bye", "Sally", "Nov 30, 2024"])
self.assertEqual(sorted_data[1][:-1], ["just want to say hi", "John", "Nov 10, 2024"])
self.assertEqual(
sorted_data[1][:-1], ["just want to say hi", "John", "Nov 10, 2024"]
)

# check date column. Skip seconds because can change during test
now = datetime.now().strftime("%Y-%m-%dT%H:%M")
Expand Down

0 comments on commit ff87ad1

Please sign in to comment.