-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Datetime formatter that shows month in english #30
Comments
I agree that this would be useful. @andrewthad what do you think? |
Yeah, I have no problem with supporting this. I wouldn’t want to hardcode the localization though, so the function would need to take a MonthMatch as an argument. This would let people pick month names in languages other than English. |
In order to simplify the implementation of data DatetimeFormat = DatetimeFormat
{ datetimeFormatDateSeparator :: !(Maybe Char)
-- ^ Separator in the date
, datetimeFormatSeparator :: !(Maybe Char)
-- ^ Separator between date and time
, datetimeFormatTimeSeparator :: !(Maybe Char)
-- ^ Separator in the time
, datetimeFormatDaysOfWeek :: !(DaysOfWeekFormat)
-- ^ How to display the day of the week
, datetimeFormatMonth :: !(MonthFormat)
-- ^ How to display the month
} deriving (Show,Read,Eq,Ord)
data DaysOfWeekFormat
= None
| Full
| Abbreviated
data MonthFormat
= Full
| Abbrevited
| Number With this configuration we describe in which mode format the |
I've not thought about the best way to proceed really, but I'm certain @chshersh and @andrewthad will have some good ideas. I may have some later. (Sorry for the apparent uselessness right now) |
@chessai sorry, but do you have thought about the best way to proceed? |
@lucazulian that wouldn't be the right approach, i don't think. it's possible that we could implement |
@chessai sorry, do you have some news? |
I thought my previous comment covered all bases, what am i not seeing? Sorry. On the subway right now. Will take a closer look in a moment. |
i think we should augment data DatetimeFormat = DatetimeFormat
{ ... currently existing fields ...
, monthFormatter :: !(MonthMatch BB.Builder)
} and have a defaultDatetimeFormat :: DatetimeFormat
defaultDatetimeFormat = DatetimeFormat
Nothing
Nothing
Nothing
(buildMonthMatch "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12") |
This would definitely be a breaking change, but perhaps useful? i'm beginning to loathe the idea of adding more and more functions that take different datatypes for ways people would like to format time. |
Any progress on this? |
Not yet, but i think my previous comment about DatetimeFormat is the way to go. Thoughts @andrewthad @chshersh? |
Currently, Decoding is a slightly different story. People often like permissive decoding. It may be trickier to unify all of these under one grand scheme. |
Localisation is difficult. A single person can't implement localisation for each language and each format. So unless somebody is going to spend a ton of money and developers time on this problem, I don't think that full generalisation is a way to go. I want to format the date like this:
And any minimal working solution is fine for me. Honestly, at this moment I'm even okay with allocating a temporary mutable array of predefined size (size is statically known in my case, it's always 31 bytes), filling it with data in the format I want and forget about this problem for several years. But this requires the library to expose all fields of the time in a friendly way. Currently, So the alternative solution could be to provide the following function instead of patching formatting data type: timeParts :: Time -> TimeParts
data TimeParts = TimeParts
{ timePartsDay :: Int
, timePartsMonth :: MonthEnum
, timePartsYear :: Int
, timePartsHour :: Int
, timePartsMinute :: Int
, timePartsSecond :: Int
, timePartsSubsecond :: Int
, timePartsTimezoneOffset :: Int
} |
@chshersh I think I agree with this. I have definitely been annoyed at the sort of 'recursive unpacking' that chronos admits. |
Okay, I think the suggested deconstruction is the best and simplest route
for now. I am going to do this if no one had a problem with it. @andrewthad?
…On Fri, Nov 8, 2019, 10:11 AM Dmitrii Kovanikov ***@***.***> wrote:
Localisation is difficult. A single person can't implement localisation
for each language and each format. So unless somebody is going to spend a
ton of money and developers time on this problem, I don't think that full
generalisation is a way to go. I want to format the date like this:
05 May 2019 11:27:43.252 +00:00
And any minimal working solution is fine for me. Honestly, at this moment
I'm even okay with allocating a temporary mutable array of predefined size
(size is statically known in my case, it's always 31 bytes), filling it
with data in the format I want and forget about this problem for several
years. But this requires the library to expose all fields of the time in a
friendly way. Currently, Time is Int64 which doesn't make it very
convenient to extract a day, month, year, hours, minutes, seconds,
sub-seconds and timezone.
So the alternative solution could be to provide the following function
instead of patching formatting data type:
timeParts :: Time -> TimeParts
data TimeParts = TimeParts
{ timePartsDay :: Int
, timePartsMonth :: MonthEnum
, timePartsYear :: Int
, timePartsHour :: Int
, timePartsMinute :: Int
, timePartsSecond :: Int
, timePartsSubsecond :: Int
, timePartsTimezoneOffset :: Int
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#30>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEOIX23C2E2WCRUBB6S3PR3QSV6Q5ANCNFSM4HK3BAHA>
.
|
released at 1.0.9 |
thanks @chshersh and @lucazulian for your continued support and interest. |
Currently I can use
builder_DmyHMS
to see the time like this:It would be nice to be able to format month in English (3 letters is enough), so I can see:
The text was updated successfully, but these errors were encountered: