[Stacomir-commits] r376 - pkg/stacomir/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jun 4 08:43:00 CEST 2017


Author: briand
Date: 2017-06-04 08:42:59 +0200 (Sun, 04 Jun 2017)
New Revision: 376

Modified:
   pkg/stacomir/R/RefHorodate.r
Log:
development
Added a decal argument to the choicemult method to enable choosing for two different years (not twice the current year) in datedebut and datefin tabs

Modified: pkg/stacomir/R/RefHorodate.r
===================================================================
--- pkg/stacomir/R/RefHorodate.r	2017-06-04 06:39:51 UTC (rev 375)
+++ pkg/stacomir/R/RefHorodate.r	2017-06-04 06:42:59 UTC (rev 376)
@@ -176,7 +176,8 @@
 setMethod("choicemult",signature=signature("RefHorodate"),definition=function(object,
 				label="date",
 				nomassign="horodate",
-				funoutlabel="nous avons le choix dans la date\n"
+				funoutlabel="nous avons le choix dans la date\n",
+				decal=0
 				) {
 				hhoro=function(h,...){
 					object=setRefHorodate(object,svalue(horodate))
@@ -186,7 +187,18 @@
 					if (svalue(notebook)<length(notebook)){
 						svalue(notebook)<-svalue(notebook)+1	
 					}
-				}				
+				}
+				if (decal!=0){
+					# Returns the first horodate of a year shifted by decal
+					# @param horodate The horodate to shift (class POSIXt)
+					# @param decal number of year to shift
+					# @return A POSIXt
+					shiftyear<-function(horodate,decal){
+						anneeprec=as.numeric(strftime(horodate,"%Y"))+decal
+						return(strptime(paste(anneeprec,"-01-01",sep=""),format="%Y-%m-%d"))
+					}
+					object at horodate<-shiftyear(object at horodate,decal)
+				}
 				if (!exists("notebook")) notebook <- gnotebook(container=group) 
 				grouphorodate<-ggroup(container=notebook, label=label,horizontal=FALSE) 
 				horodate<-gedit(getRefHorodate(object),container=grouphorodate,handler=hhoro,width=20)			



More information about the Stacomir-commits mailing list