checktime

From DavinciWiki
Jump to: navigation, search

Description

Checks whether input hours, minutes, and seconds are a valid time

Arguments and Return Values

Parameters: Numeric arrays (or scalars) specifying the hours, minutes, and seconds to be checked

Return Value: 1 if all input times are valid, 0 if any are invalid

Usage

Syntax: checktime(hours, minutes, seconds)

The inputs specifying hours, minutes, and seconds must be in that order. They do not have to be scalar. All input values of hours and minutes must be integers.

This function does not account for potential leap seconds. All input values for seconds must be greater than or equal to 0 and less than 60 in order to be considered valid.

When an input time is invalid, the function will print an error message specifying why the date is invalid. Since the function returns 0 as soon as it finds any problem, it can only specify one problem. Therefore if you input a time with multiple errors (e.g. 24:60:60), it will only explain the first mistake it found.

When checkdate() is entered without any arguments, it prints its description, as shown below.

Examples

dv> checktime()

Check for valid time (but does not allow for leap seconds)
Works for array inputs
checktime(hour, minute, second) returns 1 if input time is valid,
 0 otherwise
S.Marshall 08-12-2008

0
dv> checktime(12, 34, 56.789)
1
dv> checktime(0, 0, 0)
1
dv> checktime(24.5, 60, 60)

Error! Hour and minute must be integers!

0
dv> checktime(24, 60, 60)

Error! Hour outside valid range!

0
dv> checktime(23, 60, 60)

Error! Minute outside valid range!

0
dv> checktime(23, 59, 60)

Error! Second outside valid range!

0
dv> checktime(23, 59, 59.999)
1

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Related Functions

Recent Library Changes

Created On: 11-18-2009
Modified On: 06-01-2010

Personal tools