haskell / win32

Haskell support for the Win32 API
http://hackage.haskell.org/package/Win32
Other
98 stars 62 forks source link

Windows API date/time format pictures to `formatTime` format string #153

Closed mpilgrem closed 4 years ago

mpilgrem commented 4 years ago

Further to my recent NLS-related pull requests, I have two utility functions that translate the date or time format pictures used by the Windows API (see here and here) to the nearest equivalent format strings used by Data.Time.Format.formatTime of the time package.

For example (for locale nl-NL), Windows format picture dddd d MMMM yyyy is translated to format string %A %-e %B %Y.

Currently, they are implemented in a fork of this repository. If this package is an appropriate place for them, I'll propose a pull request. My thinking was that a 'bridge' between the Windows API and the time package could usefully be included in this package, as time may be more Unix-centric.

They are:

-- | Translate from a Windows API day, month, year, and era format picture to
-- the closest corresponding format string used by
-- 'Data.Time.Format.formatTime'.
fromDateFormatPicture :: String -> Maybe String

-- | Translate from a Windows API hour, minute, and second format picture to
-- the closest corresponding format string used by
-- 'Data.Time.Format.formatTime'.
fromTimeFormatPicture :: String -> Maybe String
Mistuke commented 4 years ago

Sure I have no problem with taking these. My only requirement is that they are not named as any existing API.