Commit 54092715 authored by Michael Hanus 's avatar Michael Hanus

Package time updated in CPM

parent 7eb4c007
Copyright (c) 2017, <AUTHOR NAME>
Copyright (c) 2020, Michael Hanus
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -9,13 +9,17 @@
"dependencies": {
"base" : ">= 3.0.0, < 4.0.0"
},
"compilerCompatibility": {
"pakcs": ">= 2.0.0",
"kics2": ">= 2.0.0"
"compilerCompatibility": {
"pakcs": ">= 3.0.0, < 4.0.0",
"kics2": ">= 3.0.0, < 4.0.0"
},
"exportedModules": [ "Data.Time" ],
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/time.git",
"tag": "$version"
}
"exportedModules": [ "Data.Time" ],
"testsuite": {
"src-dir": "test",
"modules": [ "TestTime" ]
},
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/time.git",
"tag": "$version"
}
}
......@@ -3,16 +3,16 @@
---
--- @author Michael Hanus
--- @version January 2018
--- @category general
------------------------------------------------------------------------------
module Data.Time(ClockTime,
CalendarTime(..),ctYear,ctMonth,ctDay,ctHour,ctMin,ctSec,ctTZ,
getClockTime,getLocalTime,toUTCTime,toClockTime,toCalendarTime,
clockTimeToInt,calendarTimeToString,toDayString,toTimeString,
addSeconds,addMinutes,addHours,addDays,addMonths,addYears,
daysOfMonth,validDate,compareCalendarTime,compareClockTime
) where
module Data.Time
( ClockTime, CalendarTime(..)
, ctYear, ctMonth, ctDay, ctHour, ctMin, ctSec, ctTZ
, getClockTime, getLocalTime, toUTCTime, toClockTime, toCalendarTime
, clockTimeToInt, calendarTimeToString, toDayString, toTimeString
, addSeconds, addMinutes, addHours, addDays, addMonths, addYears
, daysOfMonth, validDate, compareCalendarTime, compareClockTime
) where
--- ClockTime represents a clock time in some internal representation.
......
<?xml version="1.0" standalone="no"?>
<!DOCTYPE primitives SYSTEM "http://www.informatik.uni-kiel.de/~pakcs/primitives.dtd">
<primitives>
<primitive name="getClockTime" arity="0">
<library>prim_time</library>
<entry>prim_getClockTime</entry>
</primitive>
<primitive name="prim_toCalendarTime" arity="1">
<library>prim_time</library>
<entry>prim_toCalendarTime</entry>
</primitive>
<primitive name="prim_toUTCTime" arity="1">
<library>prim_time</library>
<entry>prim_toUTCTime</entry>
</primitive>
<primitive name="prim_toClockTime" arity="1">
<library>prim_time</library>
<entry>prim_toClockTime</entry>
</primitive>
</primitives>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Definitions of builtins of module Data.Time:
%
'Data.Time.getClockTime'('Data.Time.CTime'(CTime)) :- currentClockTime(CTime).
'Data.Time.prim_toCalendarTime'('Data.Time.CTime'(ClockTime),
'Data.Time.CalendarTime'(Year,Month,Day,Hour,Min,Sec,TZ)) :-
clocktime2localtime(ClockTime,Year,Month,Day,Hour,Min,Sec,TZ).
'Data.Time.prim_toUTCTime'('Data.Time.CTime'(ClockTime),
'Data.Time.CalendarTime'(Year,Month,Day,Hour,Min,Sec,0)) :-
clocktime2utctime(ClockTime,Year,Month,Day,Hour,Min,Sec).
'Data.Time.prim_toClockTime'('Data.Time.CalendarTime'(Year,Month,Day,Hour,
Min,Sec,TZ),
'Data.Time.CTime'(CTime)) :-
date2clocktime(Year,Month,Day,Hour,Min,Sec,TZ,CTime).
-----------------------------------------------------------------------------
-- A few tests for module Data.Time
-----------------------------------------------------------------------------
module TestTime where
import Test.Prop
import Data.Time
aTime :: CalendarTime
aTime = CalendarTime 2020 2 5 13 51 4 3600
testDayString :: Prop
testDayString = toDayString aTime -=- "February 5, 2020"
testTimeString :: Prop
testTimeString = toDayString aTime -=- "13:51:04"
testDaysOfMonth1 :: Prop
testDaysOfMonth1 = daysOfMonth 2 2020 -=- 29
testDaysOfMonth2 :: Prop
testDaysOfMonth2 = daysOfMonth 2 1900 -=- 28
testDaysOfMonth3 :: Prop
testDaysOfMonth3 = daysOfMonth 2 2000 -=- 29
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment