Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


calendarDuration

create a calendarDuration - duration in days, months and years

Syntax

c = calendarDuration(Y, M, D)
c = calendarDuration(Y, M, D, T)

c = calendarDuration(x)

c = calendarDuration(..., "OutputFormat", outputFormat)

Arguments

Y, M, D

year, month, day

real scalar or matrix

T

scalar or matrix of duration

x

m-by-3 matrix [Y, M, D] or m-by-6 matrix [Y, M, D, H, MI, S]

outputFormat

display format, string: "ymdt" (default format) or "mdt"

c

calendarDuration object.

Description

The calendarDuration function represents a duration in calendar units as days, months, and years. The months with 28, 30 or 31 days and the leap years are taken into account to compute the duration. For shorter durations like hours or minutes, see the duration function.

c = calendarDuration(Y, M, D [, T]) creates a calendarDuration object based on Y, M, D and T if specified.

c = calendarDuration(x) creates a column calendarDuration object. x contains the years, months and days, one time unit per column.

For each call of calendarDuration, we can specify the display format. This option changes only the display in Scilab console. The available formats are "ymdt" (default format) or "mdt"

Examples

calendarDuration(Y, M, D)

// calendarDuration(Y, M, D) == calyears(Y) + calmonths(M) + caldays(D)
c = calendarDuration(1, 1, 1)
c = calendarDuration(1:10, 0, 0)
c'
c = calendarDuration(0, 1:12, 0)'
c = calendarDuration(0, 0, (1:31)')

calendarDuration(Y, M, D, time)

// calendarDuration(Y, M, D, time) == calyears(Y) + calmonths(M) + caldays(D) + duration(time)
c = calendarDuration(1, 1, 1, hours(0))
c = calendarDuration(0, 0, 1, duration(12, 12, 12))
c'
c = calendarDuration(1, 1:12, 1, duration(15, 30, 0))'
c = calendarDuration(0, 0, (1:31)', duration(23, 59, 59))
c = calendarDuration(0, 0, 0, hours(0:23)')

calendarDuration(x)

c = calendarDuration([1, 1, 1])
c = calendarDuration([1, 1, 1, 23, 59, 59])
c = calendarDuration([1, 1, 1, 12, 0, 0; 2, 1, 1, 23, 0, 0])

with OutputFormat

c = calendarDuration(1, 0, 0, "OutputFormat", "mdt")
c = calendarDuration(1, 1, 0, "OutputFormat", "ymdt")
c = calendarDuration(1, 1, 0, "OutputFormat", "mdt")

Extraction - insertion - computation

c = calendarDuration(1, (8:11)', 10, duration(10, 30, 00))
c(1)
c($)
c(2:$-1)

c = matrix(c, 2, 2)
c(1, 1)
c($, 2)
c(2, :)

c(1, 2) = c(1, 2) + minutes(30)
c(2, 1) = c(2, 1) + hours(2)

With datetime

dt = datetime(1999, 10, 31)
c = calmonths(0:6)
dt + c

datetime(2022, 1, 1):caldays(15):datetime(2022, 1, 31)

See also

  • caldays — create a calendarDuration in days
  • calmonths — create a calendarDuration in months
  • calyears — create a calendarDuration in years
  • duration — create a duration - duration in hours, minutes and seconds
  • datetime — create points in time

History

VersionDescription
2024.0.0 Introduction in Scilab.
Report an issue
<< calendar Time and Date clock >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:10 CEST 2024