[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers

Title:** Hackers **
Moderator:XDELTA::HOFFMAN
Created:Sun Jan 31 1988
Last Modified:Tue May 27 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1838
Total number of notes:13578

1828.0. "Quicky C function." by CHEFS::WILLIAMSA (I wanna be Luke) Thu Feb 20 1997 11:32

    Hopefully these should be easy peasy for someone.
    
    I need some ideas for a C function that will accept an integer
    (seconds) and return a char string with the time, no dates just the
    time, ie/ pass it 85085 and it returns 23:38:05. I wrote a quick
    function to do this the other way round, and now I need something to do
    it backwards. I know there's a method of doing a sum and putting the
    remainder somewhere else, but can I remember how to do it???? (NO). Or
    how to fill in the leading zero if it's needed.
    
    I also need something that will generate as a char string the date in
    the format YYMMDD.
    
    I haven't posted these in the DECC notes conf because it's not really
    anything problem related, just me being brain dead!
    
    Any pointers or suggestions VERY gratefully received.
    
    Alen
T.RTitleUserPersonal
Name
DateLines
1828.1Y2K is upon us.STAR::GOLDENBERGRuth GoldenbergThu Feb 20 1997 12:347
    re .0
    
    Sorry I can't help with the C question, but couldn't resist asking
    isn't this the wrong end of the millenium to be generating 2-digit 
    date strings? {;)
    
    ruth
1828.2EEMELI::MOSEROrienteers do it in the bush...Thu Feb 20 1997 14:3511
	I'd use 'strftime' with which you can do fancy conversions,
	including 4-digit years etc. The snippet below is just an
	example to display the current time in a format I like.

	ftime ( &now );
	tm_ptr = localtime ( &now.time );
	i = strftime ( timestamp, 32, "%d-%b-%Y %T", tm_ptr );

	/cmos
    
1828.3MOVIES::WIDDOWSONRodFri Feb 21 1997 04:451
    Yet more C from Mr Moser ;-)
1828.450% there!!!CHEFS::WILLIAMSAI wanna be LukeFri Feb 21 1997 05:0216
    Re .1
    
    I couldn't agree more, I am all too aware of the problems of Y2K,
    however the code I'm writing is having to interogate customer generated
    files, and the customer is the one using this naming convention,
    despite our protestations (sp?).
    
    Re .2
    
    Perfect, just what I needed! Thankyou very much.
    
    As for the seconds to time business, if anyone could tell me how to do
    a division and then stick the remainder somewhere, or how about right
    justifying (with a zero) a string???
    
    Alen.
1828.5EEMELI::MOSEROrienteers do it in the bush...Fri Feb 21 1997 05:586
    re: .3
    
    I would never dare to put any of my C code frags into the DECC
    notesfile, HACKERS is just fine...   :-)
    
    /cmos
1828.6DEC C Conference Would Be Better Spot...XDELTA::HOFFMANSteve, OpenVMS EngineeringFri Feb 21 1997 09:4418
    
:    I also need something that will generate as a char string the date in
:    the format YYMMDD.

   There are RTL services present in the LIB manual that handle just about
   any format date or time you would want to use... LIB$FORMAT_DATE_TIME,
   LIB$GET_DATE_FORMAT, et al.

   If running OpenVMS V6.2 or later, see the locale support -- specifically,
   see the LC_TIME stuff -- the field descriptors %y%m%d would provide the
   requested two-digit YYMMDD format.  (This stuff is stock C, if one needs
   code portability...)

   As Ruth indicates, I'd recommend running a test with the software at this
   site -- set the date to something nearer 2000 -- and see what breaks...
   And I'd make *very* sure that the customer overrode DIGITAL's express
   objections to using a two-digit year IN WRITING.

1828.7Another snippet of "C"THEWAV::TAKASHIMASun Feb 23 1997 03:303
    Re: .4
    
            printf ("%05d\n", 42 % 39);