current-locale (empty) → 0.1.0.1
raw patch · 4 files changed
+63/−0 lines, 4 filesdep +basedep +old-localedep +processsetup-changed
Dependencies added: base, old-locale, process
Files
- LICENSE +7/−0
- Setup.hs +2/−0
- System/CurrentLocale.hs +34/−0
- current-locale.cabal +20/−0
+ LICENSE view
@@ -0,0 +1,7 @@+Copyright (c) 2012 Alexey Kotlyarov++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ System/CurrentLocale.hs view
@@ -0,0 +1,34 @@+-- |Get the current system locale in 'System.Locale' format.+module System.CurrentLocale (currentLocale) where++import System.Locale+import System.Process++format :: String -> String -> IO String+format fmt date = do+ output <- readProcess "date" ["+" ++ fmt, "-d", date] ""+ return (stripNL output)+ where stripNL x = (lines x) !! 0++formatWDay :: (String, String) -> IO (String, String)+formatWDay (wday, _) = do+ full <- format "%A" wday+ short <- format "%a" wday+ return (full, short)++formatMonth :: (String, String) -> IO (String, String)+formatMonth (month, _) = do+ let mdate = month ++ " 1"+ full <- format "%B" mdate+ short <- format "%b" mdate+ return (full, short)++-- |Get the current system locale.+currentLocale :: IO TimeLocale+currentLocale = do+ wDays <- mapM formatWDay $ wDays defaultTimeLocale+ months <- mapM formatMonth $ months defaultTimeLocale+ return defaultTimeLocale+ { wDays = wDays+ , months = months+ }
+ current-locale.cabal view
@@ -0,0 +1,20 @@+name: current-locale+version: 0.1.0.1+synopsis: Get the current system locale in System.Locale format+description:+ Use the system 'date' command to find out the current+ system locale in System.Locale format.+homepage: https://github.com/koterpillar/current-locale+license: MIT+license-file: LICENSE+author: Alexey Kotlyarov+maintainer: koterpillar@gmail.com+category: System+build-type: Simple+cabal-version: >=1.8+library+ exposed-modules: System.CurrentLocale+ build-depends: old-locale >= 1.0, process >= 1.0.1.1, base > 3 && < 5+source-repository head+ type: git+ location: git://github.com/koterpillar/current-locale.git