/
dateModified.R
56 lines (51 loc) · 1.77 KB
/
dateModified.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright (c) 2024 Apex Resource Management Solution Ltd. (ApexRMS). All rights reserved.
# MIT License
#' @include AAAClassDefinitions.R
NULL
#' Last date a SsimLibrary, Project or Scenario was modified
#'
#' The most recent modification date of a \code{\link{SsimLibrary}},
#' \code{\link{Project}} or \code{\link{Scenario}}.
#'
#' @param ssimObject \code{\link{SsimLibrary}}, \code{\link{Project}},
#' or \code{\link{Scenario}} object
#'
#' @return
#' A character string: date and time of the most recent modification
#' to the SsimObject provided as input.
#'
#' @examples
#' \dontrun{
#' # Specify file path and name of new SsimLibrary
#' myLibraryName <- file.path(tempdir(), "testlib")
#'
#' # Set up a SyncroSim Session and SsimLibrary
#' mySession <- session()
#' myLibrary <- ssimLibrary(name = myLibraryName, session = mySession)
#'
#' # Check the last date of modification of the SsimLibrary
#' dateModified(myLibrary)
#' }
#'
#' @export
setGeneric("dateModified", function(ssimObject) standardGeneric("dateModified"))
#' @rdname dateModified
setMethod("dateModified", signature(ssimObject = "character"), function(ssimObject) {
return(SyncroSimNotFound(ssimObject))
})
#' @rdname dateModified
setMethod("dateModified", signature(ssimObject = "SsimLibrary"), function(ssimObject) {
cInfo <- info(ssimObject)
property <- NULL
return(subset(cInfo, property == "Last Modified:")$value)
})
#' @rdname dateModified
setMethod("dateModified", signature(ssimObject = "Project"), function(ssimObject) {
scnInfo <- project(ssimObject, summary = TRUE)
return(scnInfo$lastModified)
})
#' @rdname dateModified
setMethod("dateModified", signature(ssimObject = "Scenario"), function(ssimObject) {
scnInfo <- scenario(ssimObject, summary = TRUE)
return(scnInfo$lastModified)
})