source: trunk/MagicSoft/slalib/ctf2d.c@ 11570

Last change on this file since 11570 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaCtf2d ( int ihour, int imin, float sec, float *days, int *j )
4/*
5** - - - - - - - - -
6** s l a C t f 2 d
7** - - - - - - - - -
8**
9** Convert hours, minutes, seconds to days.
10**
11** (single precision)
12**
13** Given:
14** ihour int hours
15** imin int minutes
16** sec float seconds
17**
18** Returned:
19** *days float interval in days
20** *j int status: 0 = OK
21** 1 = ihour outside range 0-23
22** 2 = imin outside range 0-59
23** 3 = sec outside range 0-59.999...
24**
25** Notes:
26**
27** 1) The result is computed even if any of the range checks fail.
28**
29** 2) The sign must be dealt with outside this routine.
30**
31** Last revision: 9 April 1998
32**
33** Copyright P.T.Wallace. All rights reserved.
34*/
35
36#define D2S 86400.0f /* Seconds per day */
37
38{
39/* Preset status */
40 *j = 0;
41
42/* Validate sec, min, hour */
43 if ( ( sec < 0.0f ) || ( sec >= 60.0f ) ) {
44 *j = 3;
45 return;
46 }
47 if ( ( imin < 0 ) || ( imin > 59 ) ) {
48 *j = 2;
49 return;
50 }
51 if ( ( ihour < 0 ) || ( ihour > 23 ) ) {
52 *j = 1;
53 return;
54 }
55
56/* Compute interval */
57 *days = ( 60.0f * ( 60.0f * (float) ihour + (float) imin ) + sec) / D2S;
58}
Note: See TracBrowser for help on using the repository browser.