Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Data Time Segment
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
Data Time Segment
Commits
2c6a0e18
Commit
2c6a0e18
authored
Aug 25, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] First specifications of easy dating
parent
315cbdcb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
3 deletions
+98
-3
data-time-segment.cabal
data-time-segment.cabal
+9
-0
Calendar.hs
src/Data/Time/Calendar.hs
+77
-0
stack.yaml
stack.yaml
+12
-3
No files found.
data-time-segment.cabal
View file @
2c6a0e18
...
...
@@ -18,11 +18,20 @@ library
exposed-modules: Data.Time.Segment
, Data.Time.Segment.Main
, Data.Time.Segment.Granularity
, Data.Time.Calendar
build-depends: base >= 4.7 && < 5
, time
, safe
, aeson
, clock
, iCalendar
, data-default
, wreq
, bytestring
, containers
, lens
, tagsoup
, text
default-language: Haskell2010
executable data-time-segment-exe
...
...
src/Data/Time/Calendar.hs
0 → 100644
View file @
2c6a0e18
{-# LANGUAGE OverloadedStrings #-}
module
Data.Time.Calendar
where
import
Control.Lens
((
^.
))
import
Data.ByteString.Lazy
(
ByteString
)
import
Data.Default
as
D
import
Data.Either
import
Data.List
as
List
import
Data.Map
as
Map
import
Data.Set
(
Set
)
import
Data.Set
as
Set
import
Data.String
(
String
)
import
Data.Time
as
Time
import
Network.Wreq
as
W
import
Safe
(
headMay
)
import
Text.HTML.TagSoup
as
Soup
import
Text.ICalendar.Parser
as
P
import
Text.ICalendar.Types
as
Cal
-- import Data.ByteString.Lazy (toStrict)
-- import Data.Text.Encoding (decodeUtf8)
type
Calendar
=
ByteString
type
CalendarUrl
=
String
-- Target Function
-- Let be a duration for a meeting
-- Let be a Set of remote calendar urls
-- The result of easyDating is a Map with Dates and its Participant
-- The result can be ordered according to any given policy
easyDating
::
Duration
->
Set
CalendarUrl
->
IO
(
Map
Date
(
Set
CalendarUrl
))
easyDating
=
undefined
-----------------------------------------------------------------
getDurations
::
Maybe
VCalendar
->
[(
Maybe
DTStart
,
Maybe
(
Either
DTEnd
DurationProp
))]
getDurations
Nothing
=
[]
getDurations
(
Just
vCal
)
=
Prelude
.
map
(
\
e
->
(
Cal
.
veDTStart
e
,
Cal
.
veDTEndDuration
e
))
$
Map
.
elems
$
Cal
.
vcEvents
vCal
untilNow
::
[(
Maybe
DTStart
,
Maybe
(
Either
DTEnd
DurationProp
))]
->
IO
[(
Maybe
DTStart
,
Maybe
(
Either
DTEnd
DurationProp
))]
untilNow
=
undefined
splitDuration
::
(
Date
,
Date
)
->
Duration
->
[(
Date
,
Date
)]
splitDuration
=
undefined
---------------------------------------------------------------
-- Tools to Get VCalendars
-- Local VCalendar
vCalendar
::
FilePath
->
IO
(
Maybe
VCalendar
)
vCalendar
filePath
=
do
vcal
<-
P
.
parseICalendarFile
D
.
def
filePath
(
cals
,
_
)
<-
case
vcal
of
Left
err
->
error
err
Right
res
->
pure
res
pure
$
headMay
cals
-- Remote VCalendar
-- Open Url for tests
myCalendarUrl
::
String
myCalendarUrl
=
"https://delanoe.org/nextcloud/apps/calendar/p/LwNxPHnnBRtMMqwB"
myCalendar
::
IO
ByteString
myCalendar
=
do
cal
<-
W
.
get
myCalendarUrl
pure
$
cal
^.
W
.
responseBody
remoteCalendar
::
CalendarUrl
->
IO
(
Maybe
VCalendar
)
remoteCalendar
=
undefined
-- $ P.parseICalendar D.def "/tmp/errors" cal'
---------------------------------------------------------------
stack.yaml
View file @
2c6a0e18
...
...
@@ -15,7 +15,7 @@
# resolver:
# name: custom-snapshot
# location: "./custom-snapshot.yaml"
resolver
:
lts-
8.13
resolver
:
lts-
18.28
# User packages to be built.
# Various formats can be used as shown in the example below.
...
...
@@ -39,7 +39,16 @@ packages:
-
'
.'
# Dependency packages to be pulled from upstream that are not in the resolver
# (e.g., acme-missiles-0.3)
extra-deps
:
[]
extra-deps
:
-
iCalendar-0.4.0.5@sha256:2a3dca74955de4d3548e4592201093b59328ca153ad207bad189e73cc04f4be0,1962
-
base64-bytestring-1.0.0.3@sha256:d5027ea6d63eab27cfa34eb1f5a05b6a5ee521dd176a06da3f7d80e117a88259,2352
-
containers-0.5.11.0@sha256:1af9da3baaddc4f4aaea016b07d4c38ddbf702ce3f0df31120531950837996b8,17308
-
mime-0.4.0.2@sha256:208947d9d1a19d08850be67ecb28c6e776db697f3bba05bd9d682e51a59f241f,983
-
network-2.6.3.6@sha256:1ca79d81af02d7acd6032d5e6c9bde4618a8fdcfbe19bd42b49d420183975df0,2666
-
binary-0.8.9.0@sha256:9cac9a1d86bfa3e7f75cc8bffaa256f3967ebb6d76f67a42f9679384c5c5e18a,6523
-
parsec-3.1.15.1@sha256:8c7a36aaadff12a38817fc3c4ff6c87e3352cffd1a58df640de7ed7a97ad8fa3,4601
-
text-1.2.5.0@sha256:791f0f6c97ed96113f17ab520cf0efe1a3a4f883a8c85910a5660567c8241c40,7895
-
Cabal-3.2.1.0@sha256:8743076ec022296f9771d962000c9ca3a0fe02e68c37b992c63e382a675f791d,27482
# Override default flag values for local packages and extra-deps
flags
:
{}
...
...
@@ -63,4 +72,4 @@ extra-package-dbs: []
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
\ No newline at end of file
# compiler-check: newer-minor
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment