Date program in UNIX environment

  
        

A billing program was made some time ago, which involves the calculation of the date and time. For example, when the time before (or after) a certain time of day is met, the UNIX C system itself does not provide such a function. The author has explored a function that asks for time and is now introduced to everyone.

Function introduction and parameter description;
The main function of this function is to find the date and time of the previous or the last (bill_long is negative) and its week according to the given date and time. ;

The parameters are as follows:;

s: for a given date and time, such as June 20, 2001, 18:30:04 is "20010602183004";

bill_long: the given length of time in seconds;

d_str: the date obtained, such as June 2, 2001, "20010602";

t_str: the time of the determination For example, 18:28:06 is "182806";

The function returns the value of the week, such as Sunday, 0, Monday to Saturday, respectively, 1 to 6.

Implementation Code
The concrete implementation code of this function is as follows:

int GetDateTime( char s,long int bill_long,chard_str, char t_str) {

time_t timer,tim ;

struct tm tb, tb1 ;

int year_off = 1900 ;

int mon_off = 1 ;

char s1[ ,null,null,3],20] ;

if ( strlen( s )!=14 )

return -1;

strncpy( s1, s, 4 );

S1[4] = '

Copyright © Windows knowledge All Rights Reserved