Open sarindaSenevirathne opened 2 years ago
@sarindaSenevirathne could you elaborate more about the use case?. Why do you need to do that in the first place?. Why you can't use the standard RFC3339 string that we support in the time module.
@BuddhiWathsala we are doing the above time zone conversion by defining the time zone. But if we use time:civilToString to that again, the conversion get reversed. That's why we need to format the civil record without using time:civilToString
What is the real-world use-case that you need this 2022-03-15 13:58:34
string?. AFAIK, this is not a standard format.
We exactly do not know why they need this format. We came across this since we are reviewing this customer's code and they have formated the time in this format. We do not know why they need this format
What is the real-world use-case that you need this 2022-03-15 13:58:34 string?. AFAIK, this is not a standard format.
This is not my case but in general there's still (legacy) systems out there that require non standard time formats. And those systems are not going to change so if you're going to work with them you have to adapt.
@sarindaSenevirathne could you elaborate more about the use case?. Why do you need to do that in the first place?. Why you can't use the standard RFC3339 string that we support in the time module.
@BuddhiWathsala Because in the real world scenarios we need to communicate with different not so ideal systems. Right now i have backend that accepts time in the rfc3339 format but with the mandatory milliseconds part. 2022-05-02T11:00:14.000+03:00 civilToString function strips milliseconds in this case. This leads to unwanted string manipulations and renders Time module almost useless. It would be very nice if civilToString() function has format pattern parameter. Like in any mature programming language.
Description: In this use case, what we are trying to do is convert the UTC time to the Beijing time and return the time in the string format of
2022-03-15 13:58:34
. But the civil record returns by the above-mentioned function is as follows,In there, the month, date, hour, minute and second is in the format
3
and not in the format03
. What would be the way to do this formatingThe code I am using to do the conversion -
Affected Versions: Ballerina version - Swanlake GA Time module version - 2.2.0