Closed alxndrsn closed 7 years ago
This might be implemented as an Angular filter, so that in config you can include e.g. {{bikram_sambat:edd}}
for an EDD rendered in the Nepali calendar, in place of {{edd}}
for an EDD rendered in the Gregorian calendar.
We will also want to be able to re-format dates using Bikram sambat in analytics reports, and possibly use the Bikram sambat month system to define the time periods for analytics calculations. This may inform the implementation used for this ticket.
@bishwas-medic please provide examples of how we want to format dates in EDD SMS.
Do we also want to be able to use that display date format from configuration?
Anywhere else in the app that we'd need to render these dates? What about if a nurse is filling in a form in the web app (not sure if that is relevant to the particular project in mind)? Finally, are there other use cases where we would need to support Nepali dates besides ANC?
@sglangevin yes, I'll create separate tickets for the different use cases - they're lower priority than this.
Like Gregorian date, Nepalese dates are used in a lot of formats like dd/mm/yy
, dd/mm/yyyy
, yyyy-mm-dd
, dd mmmm yyyy
, mmmm dd, yyyy
, yyyy mmmm dd
etc. The only difference being that we never use the month in the front like mm/dd/yy
.
Had a small discussion with the team here and all suggested that the following format would be the best for sending out the EDD: dd mmmm yyyy
Examples: १४ असोज २०७३
, ७ पौष २०६५
Might be useful to consider momentjs's support (or lack of) for other calendars when starting on this work: https://github.com/moment/moment/issues/1454, https://github.com/moment/moment/pull/874, https://github.com/moment/moment/issues/3068
Converter is written over at https://github.com/alxndrsn/bikram-sambat.js:
var todayInBikramSambat = require('bikram-sambat').str_toBik('2017-03-21');
This now needs hooking in somewhere so that scheduled messages can filter included variables, e.g.:
Estimated delivery date is: ${doc.edd | bikram}
It's not immediately clear to me where this should be, but perhaps in kujua-sms
.
It would also be cool to output २०७२ फागुन २३ rather than 2072-11-23, it would look more human friendly. Gonna do that next...
It would also be cool to output २०७२ फागुन २३ rather than 2072-11-23,
yeah, this should be part of the bikram-sambat lib. Will add.
If you update the BS lib to v 0.2.0, then str_toBik()
should give you dates in devanagari script.
Aarrrrgh just realized I implemented २०७३ असोज १४ instead of १४ असोज २०७३ :woman_facepalming:
(there's also PRs against your alxndrsn branches, by mistake. I closed them, ignore.)
This looks good to me, but I'm not familiar with how or when the code in medic-sentinel
gets run. Presumably this is before a message will end up in the Reports tab. Is that the case?
how or when the code in medic-sentinel gets run
When transitions add messages to a doc, they use lib/messages.js which uses lib/template.js
to render the mustache templates in the app_settings. The formatted filters are implemented there.
It's in!
AT : replace a set of {#date} ... {\date}
tags in app_settings with {#bikram_sambat_date} ... {\bikram_sambat_date}
and check it displays dates properly and doesn't mess up unicode.
I didn't test other locales than english, that might be a good idea...
@estellecomment should this be documented somewhere? Note I have no idea where, though possibly in kanso.json, or at least linked from kanso.json
Documented in medic-docs : https://github.com/medic/medic-docs/blob/master/configuration/variables_in_messages.md
Are you able to confirm that this is working as expected @bishwas-medic ? Thanks
@ngaruko yes, we have already started using this feature. I can confirm that it's working as expected. You can close the AT.
When sending EDDs in SMS messages, allow the date to be formatted using the Bikram sambat (Vikram samvat) calendar. Not to be confused with the Newari sambat (Nepal sambat) calendar.