From octave-sources-request at bevo dot che dot wisc dot edu Mon Jan 27 14:10:25 2003 Subject: month.m From: Stefan Burger To: octave-sources at bevo dot che dot wisc dot edu Date: Mon, 27 Jan 2003 08:13:28 -0600 --------------Boundary-00=_Z7MDJ3EJT5IH1CBW1GQ8 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable --------------Boundary-00=_Z7MDJ3EJT5IH1CBW1GQ8 Content-Type: text/plain; charset="us-ascii"; name="month.m" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="month.m" ## Copyright (C) 2003 Stefan Burger ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by the ## Free Software Foundation; either version 2, or (at your option) any ## later version. ## ## Octave is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.. ## ## -*- texinfo -*- ## at deftypefn {Function File} {} month (@var{Date_val}) ## Returns the month for a given date value. ## E.g., month(731597.38576) will return 1. ## If no input is specified, returns the current month. ## ## at end deftypefn ## at seealso{year, month, day, hour, minute, secondc, clock, datenum, datevec and now.) ## Author: Stefan Burger ## Description: Returns the month for a date value. function val = month(date_val) if nargin < 1 date_val = now(); %% if no input is specified, then take current time. end val = datevec(date_val)(:,2) %% extract month value / vector. %% Remember: Format is of year / month / day / hour / minute / second. %% val is column vector always. if(size(date_val)(1,1)==1) val = val'; %% make sure the answer does fit input formats row vector or column vector. endif endfunction --------------Boundary-00=_Z7MDJ3EJT5IH1CBW1GQ8--