# import
import (methods)
importFrom (graphics, par, plot, axis, axis.POSIXct, box, points, segments)
importFrom (grDevices, colors)
importFrom ('stats', start, end, weighted.mean)
importFrom (utils, head, tail)
importFrom( graphics, barplot)

export (origin, POSIXt.units)

exportClasses (TimeIntervalDataFrame, TimeInstantDataFrame, SubtimeDataFrame,
	       POSIXst)
export (as.TimeInstantDataFrame, as.TimeIntervalDataFrame,
	compute.lim, as.SubtimeDataFrame)

# generic methods (S3)
#---------------------
#POSIXcti
export ('%intersect%', '%intersect%.POSIXcti',
	'%included%', '%included%.POSIXcti',
	POSIXcti, start.POSIXcti, end.POSIXcti, format.POSIXcti, print.POSIXcti,
	'[.POSIXcti', '[<-.POSIXcti',
	Ops.POSIXcti, c.POSIXcti, unique.POSIXcti,
	format.POSIXcti, print.POSIXcti, head.POSIXcti, tail.POSIXcti,
	summary.POSIXcti, split.POSIXcti, rep.POSIXcti,
	as.POSIXcti, as.POSIXcti.logical)

S3method (start, POSIXcti)
S3method (end, POSIXcti)
S3method('%intersect%', 'POSIXcti')
S3method('%included%', 'POSIXcti')

S3method ('[', POSIXcti)
S3method ('[<-', POSIXcti)
S3method (Ops, POSIXcti)
S3method (c, POSIXcti)
S3method(unique, POSIXcti)
S3method(format, POSIXcti)
S3method(print, POSIXcti)
S3method(head, POSIXcti)
S3method(tail, POSIXcti)
S3method(summary, POSIXcti)
S3method (split, POSIXcti)
S3method (rep, POSIXcti)

S3method (as.POSIXcti, logical)

# POSIXctp
export (POSIXctp,
	'[.POSIXctp', '[<-.POSIXctp',
	Ops.POSIXctp, c.POSIXctp, unique.POSIXctp,
	format.POSIXctp, print.POSIXctp, head.POSIXctp, tail.POSIXctp,
	summary.POSIXctp, split.POSIXctp, rep.POSIXctp,
	as.POSIXctp, as.POSIXctp.logical) #, as.POSIXctp.POSIXt)

S3method ('[', POSIXctp)
S3method ('[<-', POSIXctp)
S3method (Ops, POSIXctp)
S3method (c, POSIXctp)
S3method (unique, POSIXctp)
S3method(format, POSIXctp)
S3method(print, POSIXctp)
S3method(head, POSIXctp)
S3method(tail, POSIXctp)
S3method(summary, POSIXctp)
S3method (split, POSIXctp)
S3method (rep, POSIXctp)

S3method ('as.POSIXctp', logical)
#S3method ('as.POSIXctp', 'POSIXt')

# POSIXst
export (POSIXst, POSIXst.POSIXct, POSIXst.POSIXlt, timezone.POSIXst, timezone,
	POSIXst.TimeIntervalDataFrame, POSIXst.TimeInstantDataFrame,
	POSIXst.default, POSIXst.integer, POSIXst.numeric,
	unit.POSIXst, unit, of, of.POSIXst,
	'[.POSIXst', '[<-.POSIXst',
	Ops.POSIXst, c.POSIXst, unique.POSIXst, duplicated.POSIXst,
	format.POSIXst, print.POSIXst, head.POSIXst, tail.POSIXst,
	summary.POSIXst, split.POSIXst, rep.POSIXst, seq.POSIXst)

S3method(POSIXst, POSIXct)
S3method(POSIXst, POSIXlt)
S3method(POSIXst, default)
S3method(POSIXst, integer)
S3method(POSIXst, numeric)
S3method(POSIXst, TimeIntervalDataFrame)
S3method(POSIXst, TimeInstantDataFrame)

S3method(timezone, POSIXst)
S3method(unit, POSIXst)
S3method(of, POSIXst)

S3method(format, POSIXst)
S3method(print, POSIXst)
S3method(head, POSIXst)
S3method(tail, POSIXst)
S3method(summary, POSIXst)
S3method (Ops, POSIXst)
S3method (c, POSIXst)
S3method (unique, POSIXst)
S3method (duplicated, POSIXst)
S3method ('[', POSIXst)
S3method ('[<-', POSIXst)
S3method (split, POSIXst)
S3method (rep, POSIXst)
S3method (seq, POSIXst)

# TimeIntervalDataFrame
export (rbind.TimeIntervalDataFrame, print.TimeIntervalDataFrame,
	'[.TimeIntervalDataFrame', '[<-.TimeIntervalDataFrame',
	'[[<-.TimeIntervalDataFrame',
	row.names.TimeIntervalDataFrame, 'row.names<-.TimeIntervalDataFrame',
	as.data.frame.TimeIntervalDataFrame,
	as.TimeInstantDataFrame.TimeIntervalDataFrame,
	as.SubtimeDataFrame.TimeIntervalDataFrame,
	merge.TimeIntervalDataFrame, split.TimeIntervalDataFrame,
	head.TimeIntervalDataFrame, tail.TimeIntervalDataFrame, summary.TimeIntervalDataFrame,
	start.TimeIntervalDataFrame, end.TimeIntervalDataFrame,
	plot.TimeIntervalDataFrame, lines.TimeIntervalDataFrame,
	points.TimeIntervalDataFrame, barplot.TimeIntervalDataFrame,
	TimeIntervalDataFrame, RegularTimeIntervalDataFrame)

S3method(rbind, TimeIntervalDataFrame)
S3method(print, TimeIntervalDataFrame)
S3method('[', TimeIntervalDataFrame)
S3method('[<-', TimeIntervalDataFrame)
S3method('[[<-', TimeIntervalDataFrame)
S3method(start, TimeIntervalDataFrame)
S3method(end, TimeIntervalDataFrame)

S3method(plot, TimeIntervalDataFrame)
S3method(points, TimeIntervalDataFrame)
S3method(lines, TimeIntervalDataFrame)
S3method(barplot, TimeIntervalDataFrame)

S3method(as.TimeInstantDataFrame, TimeIntervalDataFrame)
S3method(as.SubtimeDataFrame, TimeIntervalDataFrame)
S3method(as.data.frame, TimeIntervalDataFrame)

S3method(merge, TimeIntervalDataFrame)
S3method(split, TimeIntervalDataFrame)
S3method(head, TimeIntervalDataFrame)
S3method(tail, TimeIntervalDataFrame)
S3method(summary, TimeIntervalDataFrame)
S3method(row.names, TimeIntervalDataFrame)
S3method('row.names<-', TimeIntervalDataFrame)

# TimeInstantDataFrame
export (rbind.TimeInstantDataFrame, print.TimeInstantDataFrame,
	'[.TimeInstantDataFrame', '[<-.TimeInstantDataFrame',
	'[[<-.TimeInstantDataFrame',
	row.names.TimeInstantDataFrame, 'row.names<-.TimeInstantDataFrame',
	as.data.frame.TimeInstantDataFrame,
	as.TimeIntervalDataFrame.TimeInstantDataFrame,
	as.SubtimeDataFrame.TimeInstantDataFrame,
	merge.TimeInstantDataFrame, split.TimeInstantDataFrame,
	head.TimeInstantDataFrame, tail.TimeInstantDataFrame, summary.TimeInstantDataFrame,
	plot.TimeInstantDataFrame, points.TimeInstantDataFrame,
	lines.TimeInstantDataFrame, barplot.TimeInstantDataFrame,
	TimeInstantDataFrame, RegularTimeInstantDataFrame)

S3method(plot, TimeInstantDataFrame)
S3method(points, TimeInstantDataFrame)
S3method(lines, TimeInstantDataFrame)
S3method(barplot, TimeInstantDataFrame)

S3method(rbind, TimeInstantDataFrame)
S3method(print, TimeInstantDataFrame)
S3method('[', TimeInstantDataFrame)
S3method('[<-', TimeInstantDataFrame)
S3method('[[<-', TimeInstantDataFrame)

S3method(as.TimeIntervalDataFrame, TimeInstantDataFrame)
S3method(as.SubtimeDataFrame, TimeInstantDataFrame)
S3method(as.data.frame, TimeInstantDataFrame)

S3method(merge, TimeInstantDataFrame)
S3method(split, TimeInstantDataFrame)
S3method(head, TimeInstantDataFrame)
S3method(tail, TimeInstantDataFrame)
S3method(summary, TimeInstantDataFrame)
S3method(row.names, TimeInstantDataFrame)
S3method('row.names<-', TimeInstantDataFrame)

# SubtimeDataFrame
export (print.SubtimeDataFrame,
	#rbind.SubtimeDataFrame, 
	'[.SubtimeDataFrame', '[<-.SubtimeDataFrame',
	'[[<-.SubtimeDataFrame',
	as.data.frame.SubtimeDataFrame,
	merge.SubtimeDataFrame, split.SubtimeDataFrame,
	head.SubtimeDataFrame, tail.SubtimeDataFrame, summary.SubtimeDataFrame,
	plot.SubtimeDataFrame, lines.SubtimeDataFrame, points.SubtimeDataFrame,
	unit.SubtimeDataFrame, of.SubtimeDataFrame,
	SubtimeDataFrame, barplot.SubtimeDataFrame)

S3method(plot, SubtimeDataFrame)
S3method(points, SubtimeDataFrame)
S3method(lines, SubtimeDataFrame)
S3method(barplot, SubtimeDataFrame)

#S3method(rbind, SubtimeDataFrame)
S3method(print, SubtimeDataFrame)
S3method('[', SubtimeDataFrame)
S3method('[<-', SubtimeDataFrame)
S3method('[[<-', SubtimeDataFrame)

S3method(as.data.frame, SubtimeDataFrame)

S3method(unit, SubtimeDataFrame)
S3method(of, SubtimeDataFrame)
S3method(merge, SubtimeDataFrame)
S3method(split, SubtimeDataFrame)
S3method(head, SubtimeDataFrame)
S3method(tail, SubtimeDataFrame)
S3method(summary, SubtimeDataFrame)
S3method(row.names, SubtimeDataFrame)
S3method('row.names<-', SubtimeDataFrame)

# generic methods (S4)
#---------------------
exportMethods (	interval, when, period,
		regular, continuous, homogeneous, overlapping,
		'continuous<-',
		dim, length, nrow, ncol,
		names, 'names<-',
		timezone, 'timezone<-',
		changeSupport,
		show,
		'[[', '$', '$<-',
		year, month, day, hour, minute, second,
		unit, 'unit<-', duration, '+', '-', '*',
		as.numeric, match, '%in%',
		lapply, split, tapply)
