All Projects → vincenthz → hs-hourglass

vincenthz / hs-hourglass

Licence: other
efficient and simpler time API for haskell

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to hs-hourglass

Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+5455.81%)
Mutual labels:  time, datetime, date, timezone
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+4511.63%)
Mutual labels:  time, datetime, date, timezone
nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package 🇳🇵
Stars: ✭ 36 (-16.28%)
Mutual labels:  time, datetime, date, timezone
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (+4069.77%)
Mutual labels:  time, datetime, date, timezone
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (+113.95%)
Mutual labels:  time, datetime, date, timezone
Date Picker
📅 Custom responsive date picker widget for Android, written in Kotlin.
Stars: ✭ 146 (+239.53%)
Mutual labels:  time, datetime, date
Gostradamus
Gostradamus: Better DateTimes for Go 🕰️
Stars: ✭ 148 (+244.19%)
Mutual labels:  time, datetime, date
temps-lite
A smart, good-looking little app which tries to speak your language the way you are used to.
Stars: ✭ 40 (-6.98%)
Mutual labels:  time, date, timezone
Dpicker
A framework-agnostic minimal date picker
Stars: ✭ 187 (+334.88%)
Mutual labels:  time, datetime, date
time machine
A date and time API for Dart
Stars: ✭ 120 (+179.07%)
Mutual labels:  time, date, timezone
rutimeparser
Recognize date and time in russian text and return datetime.datetime.
Stars: ✭ 17 (-60.47%)
Mutual labels:  time, datetime, date
iso8601
A fast ISO8601 date parser for Go
Stars: ✭ 122 (+183.72%)
Mutual labels:  time, datetime, date
Tail.datetime
A lightweight, translat- and configurable Open Source DateTime Picker, written in pure vanilla JavaScript!
Stars: ✭ 139 (+223.26%)
Mutual labels:  time, datetime, date
Date Fns Timezone
Parsing and formatting date strings using IANA time zones for date-fns.
Stars: ✭ 118 (+174.42%)
Mutual labels:  time, date, timezone
ptera
Ptera is DateTime library for Deno
Stars: ✭ 62 (+44.19%)
Mutual labels:  time, datetime, date
qrono
🕥 Just right date time library
Stars: ✭ 111 (+158.14%)
Mutual labels:  time, datetime, date
Calendar
📅 PHP Date & Time library that solves common problems in object oriented, immutable way.
Stars: ✭ 113 (+162.79%)
Mutual labels:  time, datetime, date
date-extractor
Extract dates from text
Stars: ✭ 58 (+34.88%)
Mutual labels:  time, datetime, date
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+3074.42%)
Mutual labels:  time, datetime, date
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (+141.86%)
Mutual labels:  time, datetime, date

hourglass

Build Status BSD Haskell

Hourglass is a simple time library.

Documentation: hourglass on hackage

Design

Key parts of the design are the Timeable and Time typeclasses. Time representations of the same time values are interchangeable and easy to convert between each other. This also allows the user to define new time types that interact with the same functions as the built-in types.

For example:

let dateTime0 =
      DateTime { dtDate = Date { dateYear = 1970, dateMonth = January, dateDay = 1 }
               , dtTime = TimeOfDay {todHour = 0, todMin = 0, todSec = 0, todNSec = 0 }}
    elapsed0 = Elapsed 0

> timeGetElapsed elapsed0 == timeGetElapsed dateTime0
True
> timeGetDate elapsed0 == timeGetDate dateTime0
True
> timePrint "YYYY-MM" elapsed0
"1970-01"
> timePrint "YYYY-MM" dateTime0
"1970-01"

Hourglass has the same limitations as your system:

  • On 32 bit linux, you can't get a date after the year 2038.
  • In Windows 7, you can't get the date before the year 1601.

Comparaison with time

  • Getting posix time:
-- With time
import Data.Time.Clock.POSIX

ptime <- getPOSIXTime

-- With hourglass
import System.Hourglass

ptime <- timeCurrent
  • Getting the current year:
-- With time
import Data.Time.Clock
import Data.Time.Calendar

currentYear <- (\(y,_,_) -> y) . toGregorian . utcDay <$> getCurrentTime

-- With hourglass
import System.Hourglass
import Data.Time

currentYear <- dateYear . timeGetDate <$> timeCurrent
  • Representating "4th May 1970 15:12:24"
-- With time
import Data.Time.Clock
import Date.Time.Calendar

let day = fromGregorian 1970 5 4
    diffTime = secondsToDiffTime (15 * 3600 + 12 * 60 + 24)
in UTCTime day diffTime

-- With hourglass
import Date.Time

DateTime (Date 1970 May 4) (TimeOfDay 15 12 24 0)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].