jama5262 / jiffy

Jiffy is a Flutter (Android, IOS and Web) date time package for parsing, manipulating, querying and formatting dates
https://pub.dev/packages/jiffy
MIT License
588 stars 126 forks source link

How to remove dot? #242

Closed adrianvintu closed 1 year ago

adrianvintu commented 1 year ago

I have my locale set to german: await Jiffy.locale('de');

I print date.format('EEE do MMMM yyyy'), for example: Sa. 10. Juni 2023.

I want to remove the dot from Sa., but not from Juni. Can I do this somehow?

Needed aoutput: Sa 10. Juni 2023

kubawich commented 1 year ago

I see now way to do this with Jiffy, modify string by dart code.

jama5262 commented 1 year ago

@adrianvintu

This is not an issue with Jiffy, this is an issue with the Intl library that Jiffy runs on top off to format dates.

A hacky way will be using some kind of string manipulation, where you can remove the first found dot.

Something like this

String input = "Sa. 10. Juni 2023";

// Use a regular expression to find the first dot and replace it with nothing
String result = input.replaceFirst(RegExp(r'\.'), '');

print(result); // Output: "Sa 10. Juni 2023"
adrianvintu commented 1 year ago

Thank you @jama5262 !