CONTENT
  • CHANGES
Szukaj
counter

#top Date/Time


code / ansic / datetime

#top Makefile


Dla ułatwienia korzystania z przykładów został utworzony jeden zbiorczy plik Makefile kompilujący przykłady użycia poniżej wymienionych funkcji związanych z operacjami dotyczącymi daty i czasu.

Poniższe pliki Makefile zakładają obecność wszystkich plików przykładów, w przypadku chęci kompilacji za pomocą Makefile tylko wybranego przykładu należy zakomentować w pliku Makefile ostatnią pozycję zawierającą listę wszystkich targetów do wykonania make: $(DIFFTIME) ..., a następnie odkomentować powyżej komendę make zawierającą nazwę targetu dla bieżącego przykładu, np: w przypadku chęci kompilacji tylko przykładu gettimeofday należy zakomentować ostatnią pozycję rozpoczynającą się od make: $(DIFFTIME) ... (wstawić na początku przed make znak #), a następnie odkomentować pozycję: #make: $(DIFFTIME) (usunąć znak #).

#top Makefile (linux)


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_DYSIZE=1 -DHAVE_GETDATE=1 -DHAVE_TM_TM_ZONE=1 -DHAVE_TIMEGM=1 -DHAVE_TIMELOCAL=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ASCTIME     = asctime
CTIME       = ctime
DIFFTIME    = difftime
DYSIZE      = dysize
GETDATE     = getdate
GETTIMEOFDAY= gettimeofday
GMTIME      = gmtime
LOCALTIME   = localtime
MKTIME      = mktime
STRFTIME    = strftime
STRPTIME    = strptime
TIME        = time
TIMEGM      = timegm
TIMELOCAL   = timelocal



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ASCTIME)
#make: $(CTIME)
#make: $(DIFFTIME)
#make: $(DYSIZE)
#make: $(GETDATE)
#make: $(GETTIMEOFDAY)
#make: $(GMTIME)
#make: $(LOCALTIME)
#make: $(MKTIME)
#make: $(STRFTIME)
#make: $(STRPTIME)
#make: $(TIME)
#make: $(TIMEGM)
#make: $(TIMELOCAL)
make: $(ASCTIME) $(CTIME) $(DIFFTIME) $(DYSIZE) $(GETDATE) $(GETTIMEOFDAY) $(GMTIME) $(LOCALTIME) $(MKTIME) $(STRFTIME) $(STRPTIME) $(TIME) $(TIMEGM) $(TIMELOCAL)



$(ASCTIME): $(ASCTIME).o
	$(GCC) -o $(ASCTIME) obj/$(ASCTIME).o $(LDFLAGS)
$(ASCTIME).o:
	$(GCC) -o obj/$(ASCTIME).o -c $(ASCTIME).c $(CFLAGS)

$(CTIME): $(CTIME).o
	$(GCC) -o $(CTIME) obj/$(CTIME).o $(LDFLAGS)
$(CTIME).o:
	$(GCC) -o obj/$(CTIME).o -c $(CTIME).c $(CFLAGS)

$(DIFFTIME): $(DIFFTIME).o
	$(GCC) -o $(DIFFTIME) obj/$(DIFFTIME).o $(LDFLAGS)
$(DIFFTIME).o:
	$(GCC) -o obj/$(DIFFTIME).o -c $(DIFFTIME).c $(CFLAGS)

$(DYSIZE): $(DYSIZE).o
	$(GCC) -o $(DYSIZE) obj/$(DYSIZE).o $(LDFLAGS)
$(DYSIZE).o:
	$(GCC) -o obj/$(DYSIZE).o -c $(DYSIZE).c $(CFLAGS)

$(GETDATE): $(GETDATE).o
	$(GCC) -o $(GETDATE) obj/$(GETDATE).o $(LDFLAGS)
$(GETDATE).o:
	$(GCC) -o obj/$(GETDATE).o -c $(GETDATE).c $(CFLAGS)

$(GETTIMEOFDAY): $(GETTIMEOFDAY).o
	$(GCC) -o $(GETTIMEOFDAY) obj/$(GETTIMEOFDAY).o $(LDFLAGS)
$(GETTIMEOFDAY).o:
	$(GCC) -o obj/$(GETTIMEOFDAY).o -c $(GETTIMEOFDAY).c $(CFLAGS)

$(GMTIME): $(GMTIME).o
	$(GCC) -o $(GMTIME) obj/$(GMTIME).o $(LDFLAGS)
$(GMTIME).o:
	$(GCC) -o obj/$(GMTIME).o -c $(GMTIME).c $(CFLAGS)

$(LOCALTIME): $(LOCALTIME).o
	$(GCC) -o $(LOCALTIME) obj/$(LOCALTIME).o $(LDFLAGS)
$(LOCALTIME).o:
	$(GCC) -o obj/$(LOCALTIME).o -c $(LOCALTIME).c $(CFLAGS)

$(MKTIME): $(MKTIME).o
	$(GCC) -o $(MKTIME) obj/$(MKTIME).o $(LDFLAGS)
$(MKTIME).o:
	$(GCC) -o obj/$(MKTIME).o -c $(MKTIME).c $(CFLAGS)

$(STRFTIME): $(STRFTIME).o
	$(GCC) -o $(STRFTIME) obj/$(STRFTIME).o $(LDFLAGS)
$(STRFTIME).o:
	$(GCC) -o obj/$(STRFTIME).o -c $(STRFTIME).c $(CFLAGS)

$(STRPTIME): $(STRPTIME).o
	$(GCC) -o $(STRPTIME) obj/$(STRPTIME).o $(LDFLAGS)
$(STRPTIME).o:
	$(GCC) -o obj/$(STRPTIME).o -c $(STRPTIME).c $(CFLAGS)

$(TIME): $(TIME).o
	$(GCC) -o $(TIME) obj/$(TIME).o $(LDFLAGS)
$(TIME).o:
	$(GCC) -o obj/$(TIME).o -c $(TIME).c $(CFLAGS)

$(TIMEGM): $(TIMEGM).o
	$(GCC) -o $(TIMEGM) obj/$(TIMEGM).o $(LDFLAGS)
$(TIMEGM).o:
	$(GCC) -o obj/$(TIMEGM).o -c $(TIMEGM).c $(CFLAGS)

$(TIMELOCAL): $(TIMELOCAL).o
	$(GCC) -o $(TIMELOCAL) obj/$(TIMELOCAL).o $(LDFLAGS)
$(TIMELOCAL).o:
	$(GCC) -o obj/$(TIMELOCAL).o -c $(TIMELOCAL).c $(CFLAGS)



#top Makefile.obsd


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_TM_TM_ZONE=1 -DHAVE_TIMEGM=1 -DHAVE_TIMELOCAL=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ASCTIME     = asctime
CTIME       = ctime
DIFFTIME    = difftime
DYSIZE      = dysize
GETDATE     = getdate
GETTIMEOFDAY= gettimeofday
GMTIME      = gmtime
LOCALTIME   = localtime
MKTIME      = mktime
STRFTIME    = strftime
STRPTIME    = strptime
TIME        = time
TIMEGM      = timegm
TIMELOCAL   = timelocal



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ASCTIME)
#make: $(CTIME)
#make: $(DIFFTIME)
#make: $(DYSIZE)
#make: $(GETDATE)
#make: $(GETTIMEOFDAY)
#make: $(GMTIME)
#make: $(LOCALTIME)
#make: $(MKTIME)
#make: $(STRFTIME)
#make: $(STRPTIME)
#make: $(TIME)
#make: $(TIMEGM)
#make: $(TIMELOCAL)
make: $(ASCTIME) $(CTIME) $(DIFFTIME) $(DYSIZE) $(GETDATE) $(GETTIMEOFDAY) $(GMTIME) $(LOCALTIME) $(MKTIME) $(STRFTIME) $(STRPTIME) $(TIME) $(TIMEGM) $(TIMELOCAL)



$(ASCTIME): $(ASCTIME).o
	$(GCC) -o $(ASCTIME) obj/$(ASCTIME).o $(LDFLAGS)
$(ASCTIME).o:
	$(GCC) -o obj/$(ASCTIME).o -c $(ASCTIME).c $(CFLAGS)

$(CTIME): $(CTIME).o
	$(GCC) -o $(CTIME) obj/$(CTIME).o $(LDFLAGS)
$(CTIME).o:
	$(GCC) -o obj/$(CTIME).o -c $(CTIME).c $(CFLAGS)

$(DIFFTIME): $(DIFFTIME).o
	$(GCC) -o $(DIFFTIME) obj/$(DIFFTIME).o $(LDFLAGS)
$(DIFFTIME).o:
	$(GCC) -o obj/$(DIFFTIME).o -c $(DIFFTIME).c $(CFLAGS)

$(DYSIZE): $(DYSIZE).o
	$(GCC) -o $(DYSIZE) obj/$(DYSIZE).o $(LDFLAGS)
$(DYSIZE).o:
	$(GCC) -o obj/$(DYSIZE).o -c $(DYSIZE).c $(CFLAGS)

$(GETDATE): $(GETDATE).o
	$(GCC) -o $(GETDATE) obj/$(GETDATE).o $(LDFLAGS)
$(GETDATE).o:
	$(GCC) -o obj/$(GETDATE).o -c $(GETDATE).c $(CFLAGS)

$(GETTIMEOFDAY): $(GETTIMEOFDAY).o
	$(GCC) -o $(GETTIMEOFDAY) obj/$(GETTIMEOFDAY).o $(LDFLAGS)
$(GETTIMEOFDAY).o:
	$(GCC) -o obj/$(GETTIMEOFDAY).o -c $(GETTIMEOFDAY).c $(CFLAGS)

$(GMTIME): $(GMTIME).o
	$(GCC) -o $(GMTIME) obj/$(GMTIME).o $(LDFLAGS)
$(GMTIME).o:
	$(GCC) -o obj/$(GMTIME).o -c $(GMTIME).c $(CFLAGS)

$(LOCALTIME): $(LOCALTIME).o
	$(GCC) -o $(LOCALTIME) obj/$(LOCALTIME).o $(LDFLAGS)
$(LOCALTIME).o:
	$(GCC) -o obj/$(LOCALTIME).o -c $(LOCALTIME).c $(CFLAGS)

$(MKTIME): $(MKTIME).o
	$(GCC) -o $(MKTIME) obj/$(MKTIME).o $(LDFLAGS)
$(MKTIME).o:
	$(GCC) -o obj/$(MKTIME).o -c $(MKTIME).c $(CFLAGS)

$(STRFTIME): $(STRFTIME).o
	$(GCC) -o $(STRFTIME) obj/$(STRFTIME).o $(LDFLAGS)
$(STRFTIME).o:
	$(GCC) -o obj/$(STRFTIME).o -c $(STRFTIME).c $(CFLAGS)

$(STRPTIME): $(STRPTIME).o
	$(GCC) -o $(STRPTIME) obj/$(STRPTIME).o $(LDFLAGS)
$(STRPTIME).o:
	$(GCC) -o obj/$(STRPTIME).o -c $(STRPTIME).c $(CFLAGS)

$(TIME): $(TIME).o
	$(GCC) -o $(TIME) obj/$(TIME).o $(LDFLAGS)
$(TIME).o:
	$(GCC) -o obj/$(TIME).o -c $(TIME).c $(CFLAGS)

$(TIMEGM): $(TIMEGM).o
	$(GCC) -o $(TIMEGM) obj/$(TIMEGM).o $(LDFLAGS)
$(TIMEGM).o:
	$(GCC) -o obj/$(TIMEGM).o -c $(TIMEGM).c $(CFLAGS)

$(TIMELOCAL): $(TIMELOCAL).o
	$(GCC) -o $(TIMELOCAL) obj/$(TIMELOCAL).o $(LDFLAGS)
$(TIMELOCAL).o:
	$(GCC) -o obj/$(TIMELOCAL).o -c $(TIMELOCAL).c $(CFLAGS)



#top Makefile.fbsd


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_TM_TM_ZONE=1 -DHAVE_TIMEGM=1 -DHAVE_TIMELOCAL=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ASCTIME     = asctime
CTIME       = ctime
DIFFTIME    = difftime
DYSIZE      = dysize
GETDATE     = getdate
GETTIMEOFDAY= gettimeofday
GMTIME      = gmtime
LOCALTIME   = localtime
MKTIME      = mktime
STRFTIME    = strftime
STRPTIME    = strptime
TIME        = time
TIMEGM      = timegm
TIMELOCAL   = timelocal



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ASCTIME)
#make: $(CTIME)
#make: $(DIFFTIME)
#make: $(DYSIZE)
#make: $(GETDATE)
#make: $(GETTIMEOFDAY)
#make: $(GMTIME)
#make: $(LOCALTIME)
#make: $(MKTIME)
#make: $(STRFTIME)
#make: $(STRPTIME)
#make: $(TIME)
#make: $(TIMEGM)
#make: $(TIMELOCAL)
make: $(ASCTIME) $(CTIME) $(DIFFTIME) $(DYSIZE) $(GETDATE) $(GETTIMEOFDAY) $(GMTIME) $(LOCALTIME) $(MKTIME) $(STRFTIME) $(STRPTIME) $(TIME) $(TIMEGM) $(TIMELOCAL)



$(ASCTIME): $(ASCTIME).o
	$(GCC) -o $(ASCTIME) obj/$(ASCTIME).o $(LDFLAGS)
$(ASCTIME).o:
	$(GCC) -o obj/$(ASCTIME).o -c $(ASCTIME).c $(CFLAGS)

$(CTIME): $(CTIME).o
	$(GCC) -o $(CTIME) obj/$(CTIME).o $(LDFLAGS)
$(CTIME).o:
	$(GCC) -o obj/$(CTIME).o -c $(CTIME).c $(CFLAGS)

$(DIFFTIME): $(DIFFTIME).o
	$(GCC) -o $(DIFFTIME) obj/$(DIFFTIME).o $(LDFLAGS)
$(DIFFTIME).o:
	$(GCC) -o obj/$(DIFFTIME).o -c $(DIFFTIME).c $(CFLAGS)

$(DYSIZE): $(DYSIZE).o
	$(GCC) -o $(DYSIZE) obj/$(DYSIZE).o $(LDFLAGS)
$(DYSIZE).o:
	$(GCC) -o obj/$(DYSIZE).o -c $(DYSIZE).c $(CFLAGS)

$(GETDATE): $(GETDATE).o
	$(GCC) -o $(GETDATE) obj/$(GETDATE).o $(LDFLAGS)
$(GETDATE).o:
	$(GCC) -o obj/$(GETDATE).o -c $(GETDATE).c $(CFLAGS)

$(GETTIMEOFDAY): $(GETTIMEOFDAY).o
	$(GCC) -o $(GETTIMEOFDAY) obj/$(GETTIMEOFDAY).o $(LDFLAGS)
$(GETTIMEOFDAY).o:
	$(GCC) -o obj/$(GETTIMEOFDAY).o -c $(GETTIMEOFDAY).c $(CFLAGS)

$(GMTIME): $(GMTIME).o
	$(GCC) -o $(GMTIME) obj/$(GMTIME).o $(LDFLAGS)
$(GMTIME).o:
	$(GCC) -o obj/$(GMTIME).o -c $(GMTIME).c $(CFLAGS)

$(LOCALTIME): $(LOCALTIME).o
	$(GCC) -o $(LOCALTIME) obj/$(LOCALTIME).o $(LDFLAGS)
$(LOCALTIME).o:
	$(GCC) -o obj/$(LOCALTIME).o -c $(LOCALTIME).c $(CFLAGS)

$(MKTIME): $(MKTIME).o
	$(GCC) -o $(MKTIME) obj/$(MKTIME).o $(LDFLAGS)
$(MKTIME).o:
	$(GCC) -o obj/$(MKTIME).o -c $(MKTIME).c $(CFLAGS)

$(STRFTIME): $(STRFTIME).o
	$(GCC) -o $(STRFTIME) obj/$(STRFTIME).o $(LDFLAGS)
$(STRFTIME).o:
	$(GCC) -o obj/$(STRFTIME).o -c $(STRFTIME).c $(CFLAGS)

$(STRPTIME): $(STRPTIME).o
	$(GCC) -o $(STRPTIME) obj/$(STRPTIME).o $(LDFLAGS)
$(STRPTIME).o:
	$(GCC) -o obj/$(STRPTIME).o -c $(STRPTIME).c $(CFLAGS)

$(TIME): $(TIME).o
	$(GCC) -o $(TIME) obj/$(TIME).o $(LDFLAGS)
$(TIME).o:
	$(GCC) -o obj/$(TIME).o -c $(TIME).c $(CFLAGS)

$(TIMEGM): $(TIMEGM).o
	$(GCC) -o $(TIMEGM) obj/$(TIMEGM).o $(LDFLAGS)
$(TIMEGM).o:
	$(GCC) -o obj/$(TIMEGM).o -c $(TIMEGM).c $(CFLAGS)

$(TIMELOCAL): $(TIMELOCAL).o
	$(GCC) -o $(TIMELOCAL) obj/$(TIMELOCAL).o $(LDFLAGS)
$(TIMELOCAL).o:
	$(GCC) -o obj/$(TIMELOCAL).o -c $(TIMELOCAL).c $(CFLAGS)



#top Makefile.sol


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_GETDATE=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ASCTIME     = asctime
CTIME       = ctime
DIFFTIME    = difftime
DYSIZE      = dysize
GETDATE     = getdate
GETTIMEOFDAY= gettimeofday
GMTIME      = gmtime
LOCALTIME   = localtime
MKTIME      = mktime
STRFTIME    = strftime
STRPTIME    = strptime
TIME        = time
TIMEGM      = timegm
TIMELOCAL   = timelocal



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ASCTIME)
#make: $(CTIME)
#make: $(DIFFTIME)
#make: $(DYSIZE)
#make: $(GETDATE)
#make: $(GETTIMEOFDAY)
#make: $(GMTIME)
#make: $(LOCALTIME)
#make: $(MKTIME)
#make: $(STRFTIME)
#make: $(STRPTIME)
#make: $(TIME)
#make: $(TIMEGM)
#make: $(TIMELOCAL)
make: $(ASCTIME) $(CTIME) $(DIFFTIME) $(DYSIZE) $(GETDATE) $(GETTIMEOFDAY) $(GMTIME) $(LOCALTIME) $(MKTIME) $(STRFTIME) $(STRPTIME) $(TIME) $(TIMEGM) $(TIMELOCAL)



$(ASCTIME): $(ASCTIME).o
	$(GCC) -o $(ASCTIME) obj/$(ASCTIME).o $(LDFLAGS)
$(ASCTIME).o:
	$(GCC) -o obj/$(ASCTIME).o -c $(ASCTIME).c $(CFLAGS)

$(CTIME): $(CTIME).o
	$(GCC) -o $(CTIME) obj/$(CTIME).o $(LDFLAGS)
$(CTIME).o:
	$(GCC) -o obj/$(CTIME).o -c $(CTIME).c $(CFLAGS)

$(DIFFTIME): $(DIFFTIME).o
	$(GCC) -o $(DIFFTIME) obj/$(DIFFTIME).o $(LDFLAGS)
$(DIFFTIME).o:
	$(GCC) -o obj/$(DIFFTIME).o -c $(DIFFTIME).c $(CFLAGS)

$(DYSIZE): $(DYSIZE).o
	$(GCC) -o $(DYSIZE) obj/$(DYSIZE).o $(LDFLAGS)
$(DYSIZE).o:
	$(GCC) -o obj/$(DYSIZE).o -c $(DYSIZE).c $(CFLAGS)

$(GETDATE): $(GETDATE).o
	$(GCC) -o $(GETDATE) obj/$(GETDATE).o $(LDFLAGS)
$(GETDATE).o:
	$(GCC) -o obj/$(GETDATE).o -c $(GETDATE).c $(CFLAGS)

$(GETTIMEOFDAY): $(GETTIMEOFDAY).o
	$(GCC) -o $(GETTIMEOFDAY) obj/$(GETTIMEOFDAY).o $(LDFLAGS)
$(GETTIMEOFDAY).o:
	$(GCC) -o obj/$(GETTIMEOFDAY).o -c $(GETTIMEOFDAY).c $(CFLAGS)

$(GMTIME): $(GMTIME).o
	$(GCC) -o $(GMTIME) obj/$(GMTIME).o $(LDFLAGS)
$(GMTIME).o:
	$(GCC) -o obj/$(GMTIME).o -c $(GMTIME).c $(CFLAGS)

$(LOCALTIME): $(LOCALTIME).o
	$(GCC) -o $(LOCALTIME) obj/$(LOCALTIME).o $(LDFLAGS)
$(LOCALTIME).o:
	$(GCC) -o obj/$(LOCALTIME).o -c $(LOCALTIME).c $(CFLAGS)

$(MKTIME): $(MKTIME).o
	$(GCC) -o $(MKTIME) obj/$(MKTIME).o $(LDFLAGS)
$(MKTIME).o:
	$(GCC) -o obj/$(MKTIME).o -c $(MKTIME).c $(CFLAGS)

$(STRFTIME): $(STRFTIME).o
	$(GCC) -o $(STRFTIME) obj/$(STRFTIME).o $(LDFLAGS)
$(STRFTIME).o:
	$(GCC) -o obj/$(STRFTIME).o -c $(STRFTIME).c $(CFLAGS)

$(STRPTIME): $(STRPTIME).o
	$(GCC) -o $(STRPTIME) obj/$(STRPTIME).o $(LDFLAGS)
$(STRPTIME).o:
	$(GCC) -o obj/$(STRPTIME).o -c $(STRPTIME).c $(CFLAGS)

$(TIME): $(TIME).o
	$(GCC) -o $(TIME) obj/$(TIME).o $(LDFLAGS)
$(TIME).o:
	$(GCC) -o obj/$(TIME).o -c $(TIME).c $(CFLAGS)

$(TIMEGM): $(TIMEGM).o
	$(GCC) -o $(TIMEGM) obj/$(TIMEGM).o $(LDFLAGS)
$(TIMEGM).o:
	$(GCC) -o obj/$(TIMEGM).o -c $(TIMEGM).c $(CFLAGS)

$(TIMELOCAL): $(TIMELOCAL).o
	$(GCC) -o $(TIMELOCAL) obj/$(TIMELOCAL).o $(LDFLAGS)
$(TIMELOCAL).o:
	$(GCC) -o obj/$(TIMELOCAL).o -c $(TIMELOCAL).c $(CFLAGS)



#top Makefile.beos


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        = -DHAVE_TM_TM_ZONE=1 -DHAVE_TIMEGM=1 -DHAVE_TIMELOCAL=1
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic
LIBS        =
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = rm -f
MKDCMD      = mkdir -p

ASCTIME     = asctime
CTIME       = ctime
DIFFTIME    = difftime
DYSIZE      = dysize
GETDATE     = getdate
GETTIMEOFDAY= gettimeofday
GMTIME      = gmtime
LOCALTIME   = localtime
MKTIME      = mktime
STRFTIME    = strftime
STRPTIME    = strptime
TIME        = time
TIMEGM      = timegm
TIMELOCAL   = timelocal



all: objdir make

objdir:
	$(MKDCMD) obj/

clean: objdir
	$(RM) obj/*.o *.o *~

#make: $(ASCTIME)
#make: $(CTIME)
#make: $(DIFFTIME)
#make: $(DYSIZE)
#make: $(GETDATE)
#make: $(GETTIMEOFDAY)
#make: $(GMTIME)
#make: $(LOCALTIME)
#make: $(MKTIME)
#make: $(STRFTIME)
#make: $(STRPTIME)
#make: $(TIME)
#make: $(TIMEGM)
#make: $(TIMELOCAL)
make: $(ASCTIME) $(CTIME) $(DIFFTIME) $(DYSIZE) $(GETDATE) $(GETTIMEOFDAY) $(GMTIME) $(LOCALTIME) $(MKTIME) $(STRFTIME) $(STRPTIME) $(TIME) $(TIMEGM) $(TIMELOCAL)



$(ASCTIME): $(ASCTIME).o
	$(GCC) -o $(ASCTIME) obj/$(ASCTIME).o $(LDFLAGS)
$(ASCTIME).o:
	$(GCC) -o obj/$(ASCTIME).o -c $(ASCTIME).c $(CFLAGS)

$(CTIME): $(CTIME).o
	$(GCC) -o $(CTIME) obj/$(CTIME).o $(LDFLAGS)
$(CTIME).o:
	$(GCC) -o obj/$(CTIME).o -c $(CTIME).c $(CFLAGS)

$(DIFFTIME): $(DIFFTIME).o
	$(GCC) -o $(DIFFTIME) obj/$(DIFFTIME).o $(LDFLAGS)
$(DIFFTIME).o:
	$(GCC) -o obj/$(DIFFTIME).o -c $(DIFFTIME).c $(CFLAGS)

$(DYSIZE): $(DYSIZE).o
	$(GCC) -o $(DYSIZE) obj/$(DYSIZE).o $(LDFLAGS)
$(DYSIZE).o:
	$(GCC) -o obj/$(DYSIZE).o -c $(DYSIZE).c $(CFLAGS)

$(GETDATE): $(GETDATE).o
	$(GCC) -o $(GETDATE) obj/$(GETDATE).o $(LDFLAGS)
$(GETDATE).o:
	$(GCC) -o obj/$(GETDATE).o -c $(GETDATE).c $(CFLAGS)

$(GETTIMEOFDAY): $(GETTIMEOFDAY).o
	$(GCC) -o $(GETTIMEOFDAY) obj/$(GETTIMEOFDAY).o $(LDFLAGS)
$(GETTIMEOFDAY).o:
	$(GCC) -o obj/$(GETTIMEOFDAY).o -c $(GETTIMEOFDAY).c $(CFLAGS)

$(GMTIME): $(GMTIME).o
	$(GCC) -o $(GMTIME) obj/$(GMTIME).o $(LDFLAGS)
$(GMTIME).o:
	$(GCC) -o obj/$(GMTIME).o -c $(GMTIME).c $(CFLAGS)

$(LOCALTIME): $(LOCALTIME).o
	$(GCC) -o $(LOCALTIME) obj/$(LOCALTIME).o $(LDFLAGS)
$(LOCALTIME).o:
	$(GCC) -o obj/$(LOCALTIME).o -c $(LOCALTIME).c $(CFLAGS)

$(MKTIME): $(MKTIME).o
	$(GCC) -o $(MKTIME) obj/$(MKTIME).o $(LDFLAGS)
$(MKTIME).o:
	$(GCC) -o obj/$(MKTIME).o -c $(MKTIME).c $(CFLAGS)

$(STRFTIME): $(STRFTIME).o
	$(GCC) -o $(STRFTIME) obj/$(STRFTIME).o $(LDFLAGS)
$(STRFTIME).o:
	$(GCC) -o obj/$(STRFTIME).o -c $(STRFTIME).c $(CFLAGS)

$(STRPTIME): $(STRPTIME).o
	$(GCC) -o $(STRPTIME) obj/$(STRPTIME).o $(LDFLAGS)
$(STRPTIME).o:
	$(GCC) -o obj/$(STRPTIME).o -c $(STRPTIME).c $(CFLAGS)

$(TIME): $(TIME).o
	$(GCC) -o $(TIME) obj/$(TIME).o $(LDFLAGS)
$(TIME).o:
	$(GCC) -o obj/$(TIME).o -c $(TIME).c $(CFLAGS)

$(TIMEGM): $(TIMEGM).o
	$(GCC) -o $(TIMEGM) obj/$(TIMEGM).o $(LDFLAGS)
$(TIMEGM).o:
	$(GCC) -o obj/$(TIMEGM).o -c $(TIMEGM).c $(CFLAGS)

$(TIMELOCAL): $(TIMELOCAL).o
	$(GCC) -o $(TIMELOCAL) obj/$(TIMELOCAL).o $(LDFLAGS)
$(TIMELOCAL).o:
	$(GCC) -o obj/$(TIMELOCAL).o -c $(TIMELOCAL).c $(CFLAGS)



#top Makefile.win


SELECT ALL
# Project: Project
# Makefile created

GCC         = gcc
INCS        =
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT
CFLAGS      = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long
LIBS        = -lm
LIBDIRS     =
LDFLAGS     = $(LIBDIRS) $(LIBS)
RM          = del /q /s
MKDCMD      = mkdir

ASCTIME     = asctime
CTIME       = ctime
DIFFTIME    = difftime
DYSIZE      = dysize
GETDATE     = getdate
GETTIMEOFDAY= gettimeofday
GMTIME      = gmtime
LOCALTIME   = localtime
MKTIME      = mktime
STRFTIME    = strftime
STRPTIME    = strptime
TIME        = time
TIMEGM      = timegm
TIMELOCAL   = timelocal



all: make

objdir:
	$(MKDCMD) obj\

clean:
	$(RM) obj\*.o *.o *~

#make: $(ASCTIME)
#make: $(CTIME)
#make: $(DIFFTIME)
#make: $(DYSIZE)
#make: $(GETDATE)
#make: $(GETTIMEOFDAY)
#make: $(GMTIME)
#make: $(LOCALTIME)
#make: $(MKTIME)
#make: $(STRFTIME)
#make: $(STRPTIME)
#make: $(TIME)
#make: $(TIMEGM)
#make: $(TIMELOCAL)
make: $(ASCTIME) $(CTIME) $(DIFFTIME) $(DYSIZE) $(GETDATE) $(GETTIMEOFDAY) $(GMTIME) $(LOCALTIME) $(MKTIME) $(STRFTIME) $(STRPTIME) $(TIME) $(TIMEGM) $(TIMELOCAL)



$(ASCTIME): $(ASCTIME).o
	$(GCC) -o $(ASCTIME) obj/$(ASCTIME).o $(LDFLAGS)
$(ASCTIME).o:
	$(GCC) -o obj/$(ASCTIME).o -c $(ASCTIME).c $(CFLAGS)

$(CTIME): $(CTIME).o
	$(GCC) -o $(CTIME) obj/$(CTIME).o $(LDFLAGS)
$(CTIME).o:
	$(GCC) -o obj/$(CTIME).o -c $(CTIME).c $(CFLAGS)

$(DIFFTIME): $(DIFFTIME).o
	$(GCC) -o $(DIFFTIME) obj/$(DIFFTIME).o $(LDFLAGS)
$(DIFFTIME).o:
	$(GCC) -o obj/$(DIFFTIME).o -c $(DIFFTIME).c $(CFLAGS)

$(DYSIZE): $(DYSIZE).o
	$(GCC) -o $(DYSIZE) obj/$(DYSIZE).o $(LDFLAGS)
$(DYSIZE).o:
	$(GCC) -o obj/$(DYSIZE).o -c $(DYSIZE).c $(CFLAGS)

$(GETDATE): $(GETDATE).o
	$(GCC) -o $(GETDATE) obj/$(GETDATE).o $(LDFLAGS)
$(GETDATE).o:
	$(GCC) -o obj/$(GETDATE).o -c $(GETDATE).c $(CFLAGS)

$(GETTIMEOFDAY): $(GETTIMEOFDAY).o
	$(GCC) -o $(GETTIMEOFDAY) obj/$(GETTIMEOFDAY).o $(LDFLAGS)
$(GETTIMEOFDAY).o:
	$(GCC) -o obj/$(GETTIMEOFDAY).o -c $(GETTIMEOFDAY).c $(CFLAGS)

$(GMTIME): $(GMTIME).o
	$(GCC) -o $(GMTIME) obj/$(GMTIME).o $(LDFLAGS)
$(GMTIME).o:
	$(GCC) -o obj/$(GMTIME).o -c $(GMTIME).c $(CFLAGS)

$(LOCALTIME): $(LOCALTIME).o
	$(GCC) -o $(LOCALTIME) obj/$(LOCALTIME).o $(LDFLAGS)
$(LOCALTIME).o:
	$(GCC) -o obj/$(LOCALTIME).o -c $(LOCALTIME).c $(CFLAGS)

$(MKTIME): $(MKTIME).o
	$(GCC) -o $(MKTIME) obj/$(MKTIME).o $(LDFLAGS)
$(MKTIME).o:
	$(GCC) -o obj/$(MKTIME).o -c $(MKTIME).c $(CFLAGS)

$(STRFTIME): $(STRFTIME).o
	$(GCC) -o $(STRFTIME) obj/$(STRFTIME).o $(LDFLAGS)
$(STRFTIME).o:
	$(GCC) -o obj/$(STRFTIME).o -c $(STRFTIME).c $(CFLAGS)

$(STRPTIME): $(STRPTIME).o
	$(GCC) -o $(STRPTIME) obj/$(STRPTIME).o $(LDFLAGS)
$(STRPTIME).o:
	$(GCC) -o obj/$(STRPTIME).o -c $(STRPTIME).c $(CFLAGS)

$(TIME): $(TIME).o
	$(GCC) -o $(TIME) obj/$(TIME).o $(LDFLAGS)
$(TIME).o:
	$(GCC) -o obj/$(TIME).o -c $(TIME).c $(CFLAGS)

$(TIMEGM): $(TIMEGM).o
	$(GCC) -o $(TIMEGM) obj/$(TIMEGM).o $(LDFLAGS)
$(TIMEGM).o:
	$(GCC) -o obj/$(TIMEGM).o -c $(TIMEGM).c $(CFLAGS)

$(TIMELOCAL): $(TIMELOCAL).o
	$(GCC) -o $(TIMELOCAL) obj/$(TIMELOCAL).o $(LDFLAGS)
$(TIMELOCAL).o:
	$(GCC) -o obj/$(TIMELOCAL).o -c $(TIMELOCAL).c $(CFLAGS)





#top Predefined Constants


No predefined constants here.





#top Datatypes / MACROS


#top __suseconds_t


Definicja typu __suseconds_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __suseconds_t jest następująca:
__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds.  */



#top __time_t


Definicja typu __time_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __time_t jest następująca:
__STD_TYPE __TIME_T_TYPE __time_t;        /* Seconds since the Epoch.  */



#top __timezone_ptr_t


Definicja typu __timezone_ptr_t znajduje się w pliku nagłówkowym sys/time.h.
Definicja typu __timezone_ptr_t jest następująca:
typedef struct timezone *__restrict __timezone_ptr_t;



#top __useconds_t


Definicja typu __useconds_t znajduje się w pliku nagłówkowym bits/types.h.
Definicja typu __useconds_t jest następująca:
__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds.  */



#top getdate_err


Definicja zmiennej globalnej getdate_err znajduje się w pliku nagłówkowym time.h.
Definicja zmiennej globalnej getdate_err jest następująca:
/* Set to one of the following values to indicate an error.
     1  the DATEMSK environment variable is null or undefined,
     2  the template file cannot be opened for reading,
     3  failed to get file status information,
     4  the template file is not a regular file,
     5  an error is encountered while reading the template file,
     6  memory allication failed (not enough memory available),
     7  there is no line in the template that matches the input,
     8  invalid input specification Example: February 31 or a time is
        specified that can not be represented in a time_t (representing
    the time in seconds since 00:00:00 UTC, January 1, 1970) */
extern int getdate_err;



#top size_t


Definicja typu size_t znajduje się w pliku nagłówkowym /usr/lib/gcc/i386-redhat-linux/4.1.1/include/stddef.h.
Definicja typu size_t jest następująca:
/* Unsigned type of `sizeof' something.  */

/* Define this type if we are doing the whole job,
   or if we want this type in particular.  */
#if defined (_STDDEF_H) || defined (__need_size_t)
#ifndef __size_t__	/* BeOS */
#ifndef __SIZE_T__	/* Cray Unicos/Mk */
#ifndef _SIZE_T	/* in case <sys/types.h> has defined it. */
#ifndef _SYS_SIZE_T_H
#ifndef _T_SIZE_
#ifndef _T_SIZE
#ifndef __SIZE_T
#ifndef _SIZE_T_
#ifndef _BSD_SIZE_T_
#ifndef _SIZE_T_DEFINED_
#ifndef _SIZE_T_DEFINED
#ifndef _BSD_SIZE_T_DEFINED_	/* Darwin */
#ifndef _SIZE_T_DECLARED	/* FreeBSD 5 */
#ifndef ___int_size_t_h
#ifndef _GCC_SIZE_T
#ifndef _SIZET_
#ifndef __size_t
#define __size_t__	/* BeOS */
#define __SIZE_T__	/* Cray Unicos/Mk */
#define _SIZE_T
#define _SYS_SIZE_T_H
#define _T_SIZE_
#define _T_SIZE
#define __SIZE_T
#define _SIZE_T_
#define _BSD_SIZE_T_
#define _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED
#define _BSD_SIZE_T_DEFINED_	/* Darwin */
#define _SIZE_T_DECLARED	/* FreeBSD 5 */
#define ___int_size_t_h
#define _GCC_SIZE_T
#define _SIZET_
#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
/* __size_t is a typedef on FreeBSD 5!, must not trash it. */
#else
#define __size_t
#endif
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
#endif
#if !(defined (__GNUG__) && defined (size_t))
typedef __SIZE_TYPE__ size_t;
#ifdef __BEOS__
typedef long ssize_t;
#endif /* __BEOS__ */
#endif /* !(defined (__GNUG__) && defined (size_t)) */
#endif /* __size_t */
#endif /* _SIZET_ */
#endif /* _GCC_SIZE_T */
#endif /* ___int_size_t_h */
#endif /* _SIZE_T_DECLARED */
#endif /* _BSD_SIZE_T_DEFINED_ */
#endif /* _SIZE_T_DEFINED */
#endif /* _SIZE_T_DEFINED_ */
#endif /* _BSD_SIZE_T_ */
#endif /* _SIZE_T_ */
#endif /* __SIZE_T */
#endif /* _T_SIZE */
#endif /* _T_SIZE_ */
#endif /* _SYS_SIZE_T_H */
#endif /* _SIZE_T */
#endif /* __SIZE_T__ */
#endif /* __size_t__ */
#undef	__need_size_t
#endif /* _STDDEF_H or __need_size_t.  */



#top struct timespec


Definicja struktury struct timespec znajduje się w pliku nagłówkowym time.h.
Definicja struktury struct timespec jest następująca:
/* POSIX.1b structure for a time value.  This is like a `struct timeval' but
   has nanoseconds instead of microseconds.  */
struct timespec
  {
    __time_t tv_sec;        :* Seconds.  */
    long int tv_nsec;       /* Nanoseconds.  */
  };



#top struct timeval


Definicja struktury struct timeval znajduje się w pliku nagłówkowym bits/time.h.
Definicja struktury struct timeval jest następująca:
/* A time value that is accurate to the nearest
   microsecond but also has a range of years.  */
struct timeval
  {
    __time_t tv_sec;        :* Seconds.  */
    __suseconds_t tv_usec;  :* Microseconds.  */
  };



#top struct timezone


Definicja struktury struct timezone znajduje się w pliku nagłówkowym sys/time.h.
Definicja struktury struct timezone jest następująca:
/* Structure crudely representing a timezone.
   This is obsolete and should never be used.  */
struct timezone
  {
    int tz_minuteswest;     /* Minutes west of GMT.  */
    int tz_dsttime;     /* Nonzero if DST is ever in effect.  */
  };



#top struct tm


Definicja struktury struct tm znajduje się w pliku nagłówkowym time.h.
Definicja struktury struct tm jest następująca:
/* Used by other time functions.  */
struct tm
{
  int tm_sec;           /* Seconds. [0-60] (1 leap second) */
  int tm_min;           /* Minutes. [0-59] */
  int tm_hour;          /* Hours.   [0-23] */
  int tm_mday;          /* Day.     [1-31] */
  int tm_mon;           /* Month.   [0-11] */
  int tm_year;          /* Year - 1900.  */
  int tm_wday;          /* Day of week. [0-6] */
  int tm_yday;          /* Days in year.[0-365] */
  int tm_isdst;         /* DST.     [-1/0/1]*/

#ifdef  __USE_BSD
  long int tm_gmtoff;       /* Seconds east of UTC.  */
  __const char *tm_zone;    /* Timezone abbreviation.  */
#else
  long int __tm_gmtoff;     /* Seconds east of UTC.  */
  __const char *__tm_zone;  /* Timezone abbreviation.  */
#endif
};



#top time_t


Definicja typu time_t znajduje się w pliku nagłówkowym time.h.
Definicja typu time_t jest następująca:
#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t)
# define __time_t_defined   1

# include <bits/types.h>

__BEGIN_NAMESPACE_STD
/* Returned by `time'.  *:
typedef __time_t time_t;
__END_NAMESPACE_STD
#if defined __USE_POSIX || defined __USE_MISC || defined __USE_SVID
__USING_NAMESPACE_STD(time_t)
#endif

#endif /* time_t not defined and <time.h> or need time_t.  */



#top TIMESPEC_TO_TIMEVAL


Definicja typu TIMESPEC_TO_TIMEVAL znajduje się w pliku nagłówkowym sys/time.h.
Definicja typu TIMESPEC_TO_TIMEVAL jest następująca:
#ifdef __USE_GNU
/* Macros for converting between `struct timeval' and `struct timespec'.  *:
[...]
# define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
        (tv)->tv_sec = (ts)->tv_sec;                                    \
        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
}
#endif



#top TIMEVAL_TO_TIMESPEC


Definicja typu TIMEVAL_TO_TIMESPEC znajduje się w pliku nagłówkowym sys/time.h.
Definicja typu TIMEVAL_TO_TIMESPEC jest następująca:
#ifdef __USE_GNU
/* Macros for converting between `struct timeval' and `struct timespec'.  *:
# define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
        (ts)->tv_sec = (tv)->tv_sec;                                    \
        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
}
[...]
#endif





#top Date/Time Functions


#top asctime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji asctime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji asctime() jest następująca:
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
   that is the representation of TP in this format.  */
extern char *asctime (__const struct tm *__tp) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja asctime() zwraca łańuch znaków w postaci "Day Mon dd hh:mm:ss yyyy\n" będący reprezentacją czasu w postaci łańcucha znaków, czasu przekazanego jako wskaźnik do struktury struct tm w argumencie __tp wywołania funkcji.

Argumenty:
const struct tm *__tp - wskaźnik do struktury reprezentującej czas, który ma zostać zwrócony w postaci łańcucha znaków.

Zwracana wartość:
char * - wzkaźńik do łańcucha znaków (łańcuch znaków) w postaci "Day Mon dd hh:mm:ss yyyy\n" będący reprezentacją czasu podanego w postaci wskaźnika do struktury struct tm w argumencie __tp wywołania funkcji.
asctime using the equivalent of the following algorithm:
SELECT ALL
char *asctime(const struct tm *__tp) {
	static char wday_name[7][3] = {
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
	};
	static char mon_name[12][3] = {
		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
	};
	static char result[26];
	
	memset(result, 0x00, sizeof(result));
	snprintf(result, sizeof(result), "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", wday_name[__tp->tm_wday], mon_name[__tp->tm_mon], __tp->tm_mday, __tp->tm_hour, __tp->tm_min, __tp->tm_sec, 1900 + __tp->tm_year);
	return result;
}



#top ctime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji ctime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji ctime() jest następująca:
/* Equivalent to `asctime (localtime (timer))'.  *:
extern char *ctime (__const time_t *__timer) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja ctime() podobnie jak funkcja asctime() zwraca łańuch znaków w postaci "Day Mon dd hh:mm:ss yyyy\n" będący reprezentacją czasu w postaci łańcucha znaków, w odróżnieniu jednak od funkcji asctime() czas podany jest w postaci wskaźnika do typu time_t przekazanego w argumencie __timer wywołania funkcji.

Argumenty:
const time_t *__timer - wskaźnik do argumentu reprezentującego czas, który ma zostać zwrócony w postaci łańcucha znaków.

Zwracana wartość:
char * - wzkaźńik do łańcucha znaków (łańcuch znaków) w postaci "Day Mon dd hh:mm:ss yyyy\n" będący reprezentacją czasu podanego jako argument __timer w postaci typu time_t.
ctime() using the equivalent of the following algorithm:
SELECT ALL
char *ctime(const time_t *__timer) {
	struct tm *tp;
	static char result[26];
	
	tp=localtime(__timer);
	memset(result, 0x00, sizeof(result));
	strftime(result, sizeof(result), "%a %b %d %H:%M:%S %Y\n", tp);
	return result;
}



#top difftime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji difftime() znajduje się w pliku nagłówkowym sys/time.h.
Deklaracja funkcji difftime() jest następująca:
/* Return the difference between TIME1 and TIME0.  */
extern double difftime (time_t __time1, time_t __time0)
     __THROW __attribute__ ((__const__));

Powiązane:

Opis:
Funkcja difftime() zwraca różnice czasu w sekundach (w postaci zmiennoprzecinkowej) pomiędzy podanymi jako argumenty wywołania czasami __time1 i __time0. Podane jako argumenty czasy są timestampem określającym czas w postaci liczby sekund jaka upłynęła od początku epoki Unixa (od 1 stycznia 1970 00:00:00) wyrażonych w Coordinated Universal Time (UTC).

Argumenty:
time_t __time1 - timestamp od którego odejmowany jest czas __time0, w celu wyznaczenia różnicy czasu.
time_t __time0 - timestamp, który jest odejmowany od czasu __time1, w celu wyznaczenia różnicy czasu.

Zwracana wartość:
double - różnica czasu w sekundach (w postaci zmiennoprzecinkowej) pomiędzy czasami podanymi jako argumenty wywołania funkcji.

Example:
zawartość pliku difftime.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <time.h>          /* for struct tm, struct timespec, time(), strftime(), localtime(), */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#else
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#endif



int main(int argc, char **argv) {
	char *self;
	time_t tmarg1;
	time_t tmarg2;
	double tmdiff;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<3) {
		printf("Usage: %s <timestamp1> <timestamp2>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 1234567890 1234567895\n", argv[0]);
		return 0;
	}
	
	tmarg1=atoi(argv[1]);
	tmarg2=atoi(argv[2]);
	tmdiff=difftime(tmarg1, tmarg2);
	printf("%s: tmdiff=difftime(tmarg1=%d, tmarg2=%d): tmdiff=%f\n", self, (int)tmarg1, (int)tmarg2, tmdiff);
	tmdiff=tmarg1-tmarg2;
	printf("%s: tmdiff=tmarg1(%d)-tmarg2(%d): tmdiff=%f\n", self, (int)tmarg1, (int)tmarg2, tmdiff);
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/datetime/difftime
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/datetime/difftime <timestamp1> <timestamp2>
Examples:
       /home/local/code/ansiccode/datetime/difftime 1234567890 1234567895

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/datetime/difftime 1234567890 1234567895
rezultat będzie zależny od podanych argumentów wywołania programu:
difftime: tmdiff=difftime(tmarg1=1234567890, tmarg2=1234567895): tmdiff=-5.000000
difftime: tmdiff=tmarg1(1234567890)-tmarg2(1234567895): tmdiff=-5.000000



#top dysize


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji dysize() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji dysize() jest następująca:
/* Return the number of days in YEAR.  */
extern int dysize (int __year) __THROW  __attribute__ ((__const__));

Powiązane:

Opis:
Funkcja dysize() zwraca liczbę dni w roku podanym jako argument wywołania (z uwzględnieniem lat przestepnych).

Argumenty:
int - rok dla którego ma zostać zwrócona liczba dni.

Zwracana wartość:
int - liczba dni w roku podanym jako argument wywołania funkcji.

Example:
zawartość pliku dysize.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <time.h>          /* for struct tm, struct timespec, time(), strftime(), localtime(), */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#else
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#endif



int main(int argc, char **argv) {
	char *self;
	int yyyy;
#if defined(HAVE_DYSIZE)
	int ydays;
#endif /*defined(HAVE_DYSIZE)*/
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<2) {
		printf("Usage: %s <yyyy>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 2001\n", argv[0]);
		printf("       %s 2002\n", argv[0]);
		printf("       %s 2003\n", argv[0]);
		printf("       %s 2004\n", argv[0]);
		return 0;
	}
	
	yyyy=atoi(argv[1]);
#if defined(HAVE_DYSIZE)
	ydays=dysize(yyyy);
	printf("%s: ydays=dysize(yyyy=%d): ydays=%d\n", self, yyyy, ydays);
#else
	/* dysize() is not available on this OS platform !!! */
	printf("%s: dysize() is not available on this OS platform !!!\n", argv[0]);
#endif /*defined(HAVE_DYSIZE)*/
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/datetime/dysize
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/datetime/dysize <yyyy>
Examples:
       /home/local/code/ansiccode/datetime/dysize 2001
       /home/local/code/ansiccode/datetime/dysize 2002
       /home/local/code/ansiccode/datetime/dysize 2003
       /home/local/code/ansiccode/datetime/dysize 2004

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/datetime/dysize 2001
/home/local/code/ansiccode/datetime/dysize 2002
/home/local/code/ansiccode/datetime/dysize 2003
/home/local/code/ansiccode/datetime/dysize 2004
rezultat będzie zależny od podanych argumentów wywołania programu:
dysize: ydays=dysize(yyyy=2001): ydays=365

dysize: ydays=dysize(yyyy=2002): ydays=365

dysize: ydays=dysize(yyyy=2003): ydays=365

dysize: ydays=dysize(yyyy=2004): ydays=366



#top getdate


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji getdate() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji getdate() jest następująca:
/* Parse the given string as a date specification and return a value
   representing the value.  The templates from the file identified by
   the environment variable DATEMSK are used.  In case of an error
   `getdate_err' is set.

   This function is a possible cancellation points and therefore not
   marked with __THROW.  */
extern struct tm *getdate (__const char *__string);

Powiązane:

Opis:
Funkcja getdate() parsuje podany łańcuch znaków jako data i zwraca datę w postaci wskaźnika do struktury struct tm. Funkcja getdate() do parsowania wykorzystuje szablony formatów daty zapisane w pliku określonym zmienną środowiskową DATEMSK. W przypadku wystąpienia błędu ustawiana jest zmienna globalna getdate_err zawierająca kod błędu.

Argumenty:
const char *__string - łańcuch znaków zawierający datę (w formacie określonym w szablonie zapisanym w pliku określonym zmienną środowiskową DATEMSK).

Zwracana wartość:
struct tm * - wskaźnik do struktury będący reprezentacją czasu podanego jako argument w postaci łańcucha znaków.



#top gettimeofday


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji gettimeofday() znajduje się w pliku nagłówkowym sys/time.h.
Deklaracja funkcji gettimeofday() jest następująca:
/* Get the current time of day and timezone information,
   putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.
   Returns 0 on success, -1 on errors.
   NOTE: This form of timezone information is obsolete.
   Use the functions and variables declared in <time.h> instead.  */
extern int gettimeofday (struct timeval *__restrict __tv,
             __timezone_ptr_t __tz) __THROW __nonnull ((1));

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja gettimeofday() pobiera informacje dotyczące aktualnego czasu oraz strefy czasowej. Pobrane informacje umieszczane są we wskaźnikach podanych jako argumenty wywołania __tv oraz __tz. W przypadku gdy __tz jest NULL struktura nie jest wypełniana. W przypadku sukcesu zwracana jest wartość 0, w przeciwnym razie zwracana jest wartość -1 oraz ustawiana globalna zmienna errno określająca powód wystąpienia błędu.

Argumenty:
struct timeval *__tv - wzkaźnik do struktury w której umieszczana jest informacja dotycząca aktualnego czasu.
__timezone_ptr_t __tz - wskaźnik do struktury w której umieszczana jest informacja dotycząca strefy czasowej.

Zwracana wartość:
int - w przypadku suckesu pobrania informacji dotyczącej aktualnego czasu oraz strefy czasowej zwracana jest wartość 0, w przeciwnym razie zwracana jest wartość -1 oraz ustawiana globalna zmienna errno określająca powód wystąpienia błędu.



#top gmtime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji gmtime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji gmtime() jest następująca:
/* Return the `struct tm' representation of *TIMER
   in Universal Coordinated Time (aka Greenwich Mean Time).  */
extern struct tm *gmtime (__const time_t *__timer) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja gmtime() zwraca wskaźnik do struktury struct tm zaierającej czas w Coordinated Universal Time (UTC) dla podanego jako argument wywołania czasu w postaci wskaźniku do typu time_t.

Argumenty:
const time_t *__timer - wskaźnik do argumentu reprezentującego czas, który ma zostać zwrócony w postaci struktury wskaźnika do struktury struct tm.

Zwracana wartość:
struct tm * - wskaźnik do struktury będący reprezentacją czasu w Coordinated Universal Time (UTC) dla czasu podanego jako argument w postaci typu time_t.



#top localtime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji localtime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji localtime() jest następująca:
/* Return the `struct tm' representation
   of *TIMER in the local timezone.  */
extern struct tm *localtime (__const time_t *__timer) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja localtime() zwraca wskaźnik do struktury struct tm zaierającej czas w lokalnej strefie czasowej dla podanego jako argument wywołania czasu w postaci wskaźniku do typu time_t.

Argumenty:
time_t *__timer - wskaźnik do argumentu reprezentującego czas, który ma zostać zwrócony w postaci struktury wskaźnika do struktury struct tm.

Zwracana wartość:
struct tm * - wskaźnik do struktury będący reprezentacją czasu w strefie lokalnej dla czasu podanego jako argument w postaci typu time_t.



#top mktime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji mktime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji mktime() jest następująca:
/* Return the `time_t' representation of TP and normalize TP.  *:
extern time_t mktime (struct tm *__tp) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja mktime() zwraca czas w postaci typu time_t dla czasu podanego jako argument w postaci wskaźnika do struktury struct tm.

Argumenty:
struct tm *__tp - wskaźnik do struktury reprezentującej czas, który ma zostać zwrócony w postaci typu time_t.

Zwracana wartość:
time_t - czas w postaci typu time_t dla czasu podanego jako argument w postaci wskaźnika do struktury struct tm.

Example:
zawartość pliku mktime.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <time.h>          /* for struct tm, struct timespec, time(), strftime(), localtime(), */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#else
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#endif



int main(int argc, char **argv) {
	char *self;
	time_t timetval;
	struct tm *strtmval, tmdata;
	char datetime[ 4+1+2+1+2 +1+ 2+1+2+1+2 +1 ];
	double timestamp;
#if defined(HAVE_TM_TM_ZONE)
	char timezone[5];
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<7) {
		printf("Usage: %s <yyyy> <mm> <dd> <HH> <MM> <SS>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s 2001 02 03 04 05 06\n", argv[0]);
		return 0;
	}
	
	memset(&tmdata, 0x00, sizeof(struct tm));
	strtmval=&tmdata;
	strtmval->tm_sec=atoi(argv[6]);
	strtmval->tm_min=atoi(argv[5]);
	strtmval->tm_hour=atoi(argv[4]);
	strtmval->tm_mday=atoi(argv[3]);
	strtmval->tm_mon=atoi(argv[2]);
	strtmval->tm_year=atoi(argv[1]);
#if defined(HAVE_TM_TM_ZONE)
	memset(timezone, 0x00, sizeof(timezone));
	strncpy(timezone, "CEST", sizeof(timezone));
	strtmval->tm_zone=timezone;
#endif
	
	if (strtmval->tm_mon>0) strtmval->tm_mon=strtmval->tm_mon-1;
	if (strtmval->tm_year>=1970) strtmval->tm_year=strtmval->tm_year-1900;
	
	timestamp=mktime(strtmval);
	timetval=(time_t)timestamp;
	strtmval=localtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), "%Y/%m/%d %H:%M:%S", strtmval);
	printf("%s: timestamp=mktime(strtmval): timestamp=%f strftime(strtmval)=%s\n", self, timestamp, datetime);
	
#if defined(HAVE_TIMEGM)
	timestamp=timegm(strtmval);
	timetval=(time_t)timestamp;
	strtmval=localtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), "%Y/%m/%d %H:%M:%S", strtmval);
	printf("%s: timestamp=timegm(strtmval): timestamp=%f strftime(strtmval)=%s\n", self, timestamp, datetime);
#else
	/* timegm() is not available on this OS platform !!! */
	printf("%s: timegm() is not available on this OS platform !!!\n", argv[0]);
#endif
	
#if defined(HAVE_TIMELOCAL)
	timestamp=timelocal(strtmval);
	timetval=(time_t)timestamp;
	strtmval=localtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), "%Y/%m/%d %H:%M:%S", strtmval);
	printf("%s: timestamp=timelocal(strtmval): timestamp=%f strftime(strtmval)=%s\n", self, timestamp, datetime);
#else
	/* timelocal() is not available on this OS platform !!! */
	printf("%s: timelocal() is not available on this OS platform !!!\n", argv[0]);
#endif
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/datetime/mktime
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/datetime/mktime <yyyy> <mm> <dd> <HH> <MM> <SS>
Examples:
       /home/local/code/ansiccode/datetime/mktime 2001 02 03 04 05 06

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/datetime/mktime 2001 02 03 04 05 06
rezultat będzie zależny od podanych argumentów wywołania programu:
mktime: timestamp=mktime(strtmval): timestamp=981169506.000000 strftime(strtmval)=2001/02/03 04:05:06
mktime: timestamp=timegm(strtmval): timestamp=981173106.000000 strftime(strtmval)=2001/02/03 05:05:06
mktime: timestamp=timelocal(strtmval): timestamp=981173106.000000 strftime(strtmval)=2001/02/03 05:05:06



#top strftime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji strftime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji strftime() jest następująca:
/* Format TP into S according to FORMAT.
   Write no more than MAXSIZE characters and return the number
   of characters written, or 0 if it would exceed MAXSIZE.  */
extern size_t strftime (char *__restrict __s, size_t __maxsize,
            __const char *__restrict __format,
            __const struct tm *__restrict __tp) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja strftime() formatuje czas podany jako wskaźnik do struktury struct tm wypełniając podany jako argument wskaźńik do bufora łańucha znaków __s (jednak nie więcej niż podany rozmiar bufora łańucha znaków __maxsize) zgodnie z podanym formatem w argumencie __format. Zwracana wartość zawiera ilość znaków umieszczonych w buforze podanym jako wskaźnik (łańcuch znaków) lub 0 w przypadku gdy podany rozmiar bufora jest zbyt mały aby wypełnić w nim całości czas zgodnie z podanym formatem.

Argumenty:
char *__s - wskaźnik do bufora w którym zwracany jest czas w zgodny z podanym formatem.
size_t __maxsize - rozmiar bufora w którym zostanie zwrócony czas zgodnym z podany formatem.
Local timezone information is used as though strftime() called tzset().
%a is replaced by the locale's abbreviated weekday name.
%A is replaced by the locale's full weekday name.
%b is replaced by the locale's abbreviated month name.
%B is replaced by the locale's full month name.
%c is replaced by the locale's appropriate date and time representation.
%C is replaced by the century number (the year divided by 100 and truncated to an integer) as a decimal number [00-99].
%d is replaced by the day of the month as a decimal number [01,31].
%D same as %m/%d/%y.
%e is replaced by the day of the month as a decimal number [1,31]; a single digit is preceded by a space.
%h same as %b.
%H is replaced by the hour (24-hour clock) as a decimal number [00,23].
%I is replaced by the hour (12-hour clock) as a decimal number [01,12].
%j is replaced by the day of the year as a decimal number [001,366].
%m is replaced by the month as a decimal number [01,12].
%M is replaced by the minute as a decimal number [00,59].
%n is replaced by a newline character.
%p is replaced by the locale's equivalent of either a.m. or p.m.
%r is replaced by the time in a.m. and p.m. notation; in the POSIX locale this is equivalent to %I:%M:%S %p.
%R is replaced by the time in 24 hour notation (%H:%M).
%S is replaced by the second as a decimal number [00,61].
%t is replaced by a tab character.
%T is replaced by the time (%H:%M:%S).
%u is replaced by the weekday as a decimal number [1,7], with 1 representing Monday.
%U is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
%V is replaced by the week number of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1.
%w is replaced by the weekday as a decimal number [0,6], with 0 representing Sunday.
%W is replaced by the week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.
%x is replaced by the locale's appropriate date representation.
%X is replaced by the locale's appropriate time representation.
%y is replaced by the year without century as a decimal number [00,99].
%Y is replaced by the year with century as a decimal number.
%Z is replaced by the timezone name or abbreviation, or by no bytes if no timezone information exists.
%% is replaced by %.
If a conversion specification does not correspond to any of the above, the behaviour is undefined.

Modified Conversion Specifiers
Some conversion specifiers can be modified by the E or O modifier characters to indicate that an alternative format or specification should be used rather than the one normally used by the unmodified conversion specifier. If the alternative format or specification does not exist for the current locale, (see ERA in the XBD specification, Section 5.3.5) the behaviour will be as if the unmodified conversion specification were used.
%Ec is replaced by the locale's alternative appropriate date and time representation.
%EC is replaced by the name of the base year (period) in the locale's alternative representation.
%Ex is replaced by the locale's alternative date representation.
%EX is replaced by the locale' alternative time representation.
%Ey is replaced by the offset from %EC (year only) in the locale's alternative representation.
%EY is replaced by the full alternative year representation.
%Od is replaced by the day of the month, using the locale's alternative numeric symbols, filled as needed with leading zeros if there is any alternative symbol for zero, otherwise with leading spaces.
%Oe is replaced by the day of month, using the locale's alternative numeric symbols, filled as needed with leading spaces.
%OH is replaced by the hour (24-hour clock) using the locale's alternative numeric symbols.
%OI is replaced by the hour (12-hour clock) using the locale's alternative numeric symbols.
%Om is replaced by the month using the locale's alternative numeric symbols.
%OM is replaced by the minutes using the locale's alternative numeric symbols.
%OS is replaced by the seconds using the locale's alternative numeric symbols.
%Ou is replaced by the weekday as a number in the locale's alternative representation (Monday=1).
%OU is replaced by the week number of the year (Sunday as the first day of the week, rules corresponding to %U) using the locale's alternative numeric symbols.
%OV is replaced by the week number of the year (Monday as the first day of the week, rules corresponding to %V) using the locale's alternative numeric symbols.
%Ow is replaced by the number of the weekday (Sunday=0) using the locale's alternative numeric symbols.
%OW is replaced by the week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols.
%Oy is replaced by the year (offset from %C) using the locale's alternative numeric symbols.
const char *__format - format w jakim zostanie zwrócony czas we wskaźniku do bufora znaków.
const struct tm *__tp - czas który zostanie zwrócony we wskaźniku do bufora znaków.

Zwracana wartość:
size_t - ilość znaków umieszczonych w buforze podanym jako wskaźnik (łańcuch znaków) lub 0 w przypadku gdy podany rozmiar bufora jest zbyt mały aby wypełnić w nim całości czas zgodnie z podanym formatem.

Example:
zawartość pliku strftime.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <time.h>          /* for struct tm, struct timespec, time(), strftime(), localtime(), */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#else
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#endif



int main(int argc, char **argv) {
	char *self;
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	long int inttime;
	SYSTEMTIME psystime;
#else
	struct timezone tz1;
	struct timeval tv1;
	struct tm *tm1;
#endif
	time_t timetval;
	struct tm *strtmval;
	char datetime[ /*4+1+2+1+2 +1+ 2+1+2+1+2 +1*/ 256 ];
	double timestamp;
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<3) {
		printf("Usage: %s \"timeformat\" <timestamp>\n", argv[0]);
		printf("Examples:\n");
		printf("       %s \"%%Y/%%m/%%d %%H:%%M:%%S\" 1234567890\n", argv[0]);
		printf("       %s \"%%b %%d %%H:%%M:%%S\" 1234567890\n", argv[0]);
		printf("       %s \"%%a, %%d %%b %%Y %%H:%%M:%%S %%z\" 1234567890\n", argv[0]);
		return 0;
	}
	
	timestamp=atof(argv[2]);
	
	timetval=(time_t)timestamp;
	strtmval=localtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), argv[1], strtmval);
	printf("%s: timestamp=%f datetime=%s\n", self, timestamp, datetime);
	
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	time(&inttime);
	GetLocalTime(&psystime);
	timestamp=(double)inttime+(double)psystime.wMilliseconds/1024;
#else
	gettimeofday(&tv1, &tz1);
	tm1=localtime((time_t*)&tv1.tv_sec);
	timestamp=((double)tv1.tv_sec+(double)tv1.tv_usec/1E6);
#endif
	
	timetval=(time_t)timestamp;
	strtmval=gmtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), argv[1], strtmval);
	printf("%s: timestamp=%f gmtime(&timetval): strftime(strtmval)=|%s|\n", self, timestamp, datetime);
	printf("%s: timestamp=%f gmtime(&timetval): asctime(strtmval)=|%s|\n", self, timestamp, asctime(strtmval));
	printf("%s: timestamp=%f gmtime(&timetval): ctime(&timetval)=|%s|\n", self, timestamp, ctime(&timetval));
	
	timetval=(time_t)timestamp;
	strtmval=localtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), argv[1], strtmval);
	printf("%s: timestamp=%f localtime(&timetval): strftime(strtmval)=|%s|\n", self, timestamp, datetime);
	printf("%s: timestamp=%f localtime(&timetval): asctime(strtmval)=|%s|\n", self, timestamp, asctime(strtmval));
	printf("%s: timestamp=%f localtime(&timetval): ctime(&timetval)=|%s|\n", self, timestamp, ctime(&timetval));
	
	timetval=time(NULL);
	strtmval=localtime(&timetval);
	memset(datetime, 0x00, sizeof(datetime));
	strftime(datetime, sizeof(datetime), argv[1], strtmval);
	printf("%s: timetval=time(): timetval=%ld strftime(strtmval)=|%s|\n", self, (long int)timetval, datetime);
	printf("%s: timetval=time(): timetval=%ld asctime(strtmval)=|%s|\n", self, (long int)timetval, asctime(strtmval));
	printf("%s: timetval=time(): timetval=%ld ctime(&timetval)=|%s|\n", self, (long int)timetval, ctime(&timetval));
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/datetime/strftime
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/datetime/strftime "timeformat" <timestamp>
Examples:
       /home/local/code/ansiccode/datetime/strftime "%Y/%m/%d %H:%M:%S" 1234567890
       /home/local/code/ansiccode/datetime/strftime "%b %d %H:%M:%S" 1234567890
       /home/local/code/ansiccode/datetime/strftime "%a, %d %b %Y %H:%M:%S %z" 1234567890

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/datetime/strftime "%Y/%m/%d %H:%M:%S" 1234567890
/home/local/code/ansiccode/datetime/strftime "%b %d %H:%M:%S" 1234567890
/home/local/code/ansiccode/datetime/strftime "%a, %d %b %Y %H:%M:%S %z" 1234567890
rezultat będzie zależny od podanych argumentów wywołania programu:
strftime: timestamp=1234567890.000000 datetime=2009/02/14 00:31:30
strftime: timestamp=1395923063.258911 gmtime(&timetval): strftime(strtmval)=|2014/03/27 12:24:23|
strftime: timestamp=1395923063.258911 gmtime(&timetval): asctime(strtmval)=|Thu Mar 27 12:24:23 2014
|
strftime: timestamp=1395923063.258911 gmtime(&timetval): ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|
strftime: timestamp=1395923063.258911 localtime(&timetval): strftime(strtmval)=|2014/03/27 13:24:23|
strftime: timestamp=1395923063.258911 localtime(&timetval): asctime(strtmval)=|Thu Mar 27 13:24:23 2014
|
strftime: timestamp=1395923063.258911 localtime(&timetval): ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|
strftime: timetval=time(): timetval=1395923063 strftime(strtmval)=|2014/03/27 13:24:23|
strftime: timetval=time(): timetval=1395923063 asctime(strtmval)=|Thu Mar 27 13:24:23 2014
|
strftime: timetval=time(): timetval=1395923063 ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|

strftime: timestamp=1234567890.000000 datetime=Feb 14 00:31:30
strftime: timestamp=1395923063.270625 gmtime(&timetval): strftime(strtmval)=|Mar 27 12:24:23|
strftime: timestamp=1395923063.270625 gmtime(&timetval): asctime(strtmval)=|Thu Mar 27 12:24:23 2014
|
strftime: timestamp=1395923063.270625 gmtime(&timetval): ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|
strftime: timestamp=1395923063.270625 localtime(&timetval): strftime(strtmval)=|Mar 27 13:24:23|
strftime: timestamp=1395923063.270625 localtime(&timetval): asctime(strtmval)=|Thu Mar 27 13:24:23 2014
|
strftime: timestamp=1395923063.270625 localtime(&timetval): ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|
strftime: timetval=time(): timetval=1395923063 strftime(strtmval)=|Mar 27 13:24:23|
strftime: timetval=time(): timetval=1395923063 asctime(strtmval)=|Thu Mar 27 13:24:23 2014
|
strftime: timetval=time(): timetval=1395923063 ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|

strftime: timestamp=1234567890.000000 datetime=Sat, 14 Feb 2009 00:31:30 +0100
strftime: timestamp=1395923063.288025 gmtime(&timetval): strftime(strtmval)=|Thu, 27 Mar 2014 12:24:23 +0000|
strftime: timestamp=1395923063.288025 gmtime(&timetval): asctime(strtmval)=|Thu Mar 27 12:24:23 2014
|
strftime: timestamp=1395923063.288025 gmtime(&timetval): ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|
strftime: timestamp=1395923063.288025 localtime(&timetval): strftime(strtmval)=|Thu, 27 Mar 2014 13:24:23 +0100|
strftime: timestamp=1395923063.288025 localtime(&timetval): asctime(strtmval)=|Thu Mar 27 13:24:23 2014
|
strftime: timestamp=1395923063.288025 localtime(&timetval): ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|
strftime: timetval=time(): timetval=1395923063 strftime(strtmval)=|Thu, 27 Mar 2014 13:24:23 +0100|
strftime: timetval=time(): timetval=1395923063 asctime(strtmval)=|Thu Mar 27 13:24:23 2014
|
strftime: timetval=time(): timetval=1395923063 ctime(&timetval)=|Thu Mar 27 13:24:23 2014
|



#top strptime


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji strptime() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji strptime() jest następująca:
/* Parse S according to FORMAT and store binary time information in TP.
   The return value is a pointer to the first unparsed character in S.  */
extern char *strptime (__const char *__restrict __s,
               __const char *__restrict __fmt, struct tm *__tp)
     __THROW;

Powiązane:

Opis:
Funkcja strptime() parsuje datę w podanym jako argument wywołania łańcuchu znaków __s w formacie określonym w argumencie __fmt i umieszcza datę we skaźniku do struktury struct tm.

Argumenty:
const char *__s - łańcuch znaków reprezentujący datę, która ma zostać zwrócona we wskaźniku do struktury struct tm.
const char *__fmt - format daty przekazanej w łańcuchu znaków, która ma zostać zwrócona we wskaźniku do struktury struct tm.
The following conversion specifications are supported:
%a is the day of week, using the locale's weekday names; either the abbreviated or full name may be specified.
%A is the same as %a.
%b is the month, using the locale's month names; either the abbreviated or full name may be specified.
%B is the same as %b.
%c is replaced by the locale's appropriate date and time representation.
%C is the century number [0,99]; leading zeros are permitted but not required.
%d is the day of month [1,31]; leading zeros are permitted but not required.
%D is the date as %m/%d/%y.
%e is the same as %d.
%h is the same as %b.
%H is the hour (24-hour clock) [0,23]; leading zeros are permitted but not required.
%I is the hour (12-hour clock) [1,12]; leading zeros are permitted but not required.
%j is the day number of the year [1,366]; leading zeros are permitted but not required.
%m is the month number [1,12]; leading zeros are permitted but not required.
%M is the minute [0-59]; leading zeros are permitted but not required.
%n is any white space.
%p is the locale's equivalent of a.m or p.m.
%r 12-hour clock time using the AM/PM notation if t_fmt_ampm is not an empty string in the LC_TIME portion of the current locale; in the POSIX locale, this will be equivalent to %I:%M:%S %p.
%R is the time as %H:%M.
%S is the seconds [0,61]; leading zeros are permitted but not required.
%t is any white space.
%T is the time as %H:%M:%S.
%U is the week number of the year (Sunday as the first day of the week) as a decimal number [00,53]; leading zeros are permitted but not required.
%w is the weekday as a decimal number [0,6], with 0 representing Sunday; leading zeros are permitted but not required.
%W is the the week number of the year (Monday as the first day of the week) as a decimal number [00,53]; leading zeros are permitted but not required.
%x is the date, using the locale's date format.
%X is the time, using the locale's time format.
%y is the year within century. When a century is not otherwise specified, values in the range 69-99 refer to years in the twentieth century (1969 to 1999 inclusive); values in the range 00-68 refer to years in the twenty-first century (2000 to 2068 inclusive). Leading zeros are permitted but not required.
%Y is the year, including the century (for example, 1988).
%% is replaced by %.

Modified Directives
Some directives can be modified by the E and O modifier characters to indicate that an alternative format or specification should be used rather than the one normally used by the unmodified directive. If the alternative format or specification does not exist in the current locale, the behaviour will be as if the unmodified directive were used.
%Ec is the locale's alternative appropriate date and time representation.
%EC is the name of the base year (period) in the locale's alternative representation.
%Ex is the locale's alternative date representation.
%EX is the locale's alternative time representation.
%Ey is the offset from %EC (year only) in the locale's alternative representation.
%EY is the full alternative year representation.
%Od is the day of the month using the locale's alternative numeric symbols; leading zeros are permitted but not required.
%Oe is the same as %Od.
%OH is the hour (24-hour clock) using the locale's alternative numeric symbols.
%OI is the hour (12-hour clock) using the locale's alternative numeric symbols.
%Om is the month using the locale's alternative numeric symbols.
%OM is the minutes using the locale's alternative numeric symbols.
%OS is the seconds using the locale's alternative numeric symbols.
%OU is the week number of the year (Sunday as the first day of the week) using the locale's alternative numeric symbols.
%Ow is the number of the weekday (Sunday=0) using the locale's alternative numeric symbols.
%OW is the week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols.
%Oy is the year (offset from %C) using the locale's alternative numeric symbols.
A directive composed of white-space characters is executed by scanning input up to the first character that is not white-space (which remains unscanned), or until no more characters can be scanned.
A directive that is an ordinary character is executed by scanning the next character from the buffer. If the character scanned from the buffer differs from the one comprising the directive, the directive fails, and the differing and subsequent characters remain unscanned.
A series of directives composed of %n, %t, white-space characters or any combination is executed by scanning up to the first character that is not white space (which remains unscanned), or until no more characters can be scanned.
struct tm *__tp - wskaźnik do struktury struct tm w której ma zostać zwrócona parsowana data.

Zwracana wartość:
char * - wskaźnik do pierwszego znaku, który nie został dopasowany do podanego formatu daty.

Example:
zawartość pliku strptime.c
SELECT ALL
#define  _GNU_SOURCE  1    /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */
#include <stdio.h>         /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */
                           /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */
                           /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */
#include <stdlib.h>        /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */
                           /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */
                           /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */
#include <string.h>        /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */
                           /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */
#include <time.h>          /* for struct tm, struct timespec, time(), strftime(), localtime(), */

#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>     /* for windef.h, wincon.h, winbase.h, winuser.h, winver.h, winsock.h, */
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#else
  #include <sys/time.h>    /* for struct timezone, struct timeval, gettimeofday(), settimeofday(), utimes(), lutimes(), */
#endif



int main(int argc, char **argv) {
	char *self;
	struct tm *strtm, strdata;
	char datetime[ 4+1+2+1+2 +1+ 2+1+2+1+2 +1 ];
#if defined(HAVE_GETDATE)
	char dateerrs[128];
#endif
	
	self=strrchr(argv[0], '/');
	if (self!=NULL) self++;
	else self=argv[0];
	
	if (argc<3) {
		printf("Usage: %s <timestring> <timeformat>\n", argv[0]);
		printf("Examples:\n");
		printf("       DATEMSK=/home/local/code/ansiccode/datetime/datemsk %s \"2001/02/03 04:05:06\" \"%%Y/%%m/%%d %%H:%%M:%%S\"\n", argv[0]);
		printf("       DATEMSK=/home/local/code/ansiccode/datetime/datemsk %s \"2001-02-03 04:05:06\" \"%%Y-%%m-%%d %%H:%%M:%%S\"\n", argv[0]);
		printf("       DATEMSK=/home/local/code/ansiccode/datetime/datemsk %s \"2013 Feb 03 04:05:06\" \"%%Y %%b %%d %%H:%%M:%%S\"\n", argv[0]);
		printf("       DATEMSK=/home/local/code/ansiccode/datetime/datemsk %s \"Sun, 15 Sep 2013 05:02:12\" \"%%a, %%d %%b %%Y %%H:%%M:%%S\"\n", argv[0]);
		printf("\n");
		printf("Contents /home/local/code/ansiccode/datetime/datemsk\n");
		printf("----------------------------------------------------\n");
		printf("%%Y/%%m/%%d %%H:%%M:%%S\n");
		printf("%%Y-%%m-%%d %%H:%%M:%%S\n");
		printf("%%Y %%b %%d %%H:%%M:%%S\n");
		printf("%%a, %%d %%b %%Y %%H:%%M:%%S\n");
		return 0;
	}
	
	memset(&strdata, 0x00, sizeof(struct tm));
	strtm=&strdata;
	memset(datetime, 0x00, sizeof(datetime));
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32)
	/* strptime() is not available on this OS platform !!! */
	printf("%s: strptime() is not available on this OS platform !!!\n", argv[0]);
#else
	strptime(argv[1], argv[2], strtm);
	strftime(datetime, sizeof(datetime), "%Y/%m/%d %H:%M:%S", strtm);
	printf("%s: strptime(argv[1]=%s, argv[2]=%s, strtm): datetime=%s\n", self, argv[1], argv[2], datetime);
#endif
	
#if defined(HAVE_GETDATE)
	strtm=getdate(argv[1]);
	if (strtm!=NULL) {
		strftime(datetime, sizeof(datetime), "%Y/%m/%d %H:%M:%S", strtm);
		printf("%s: strtm=getdate(argv[1]=%s): if (strtm!=NULL): datetime=%s\n", self, argv[1], datetime);
	} else {
/* Set to one of the following values to indicate an error.
     1  the DATEMSK environment variable is null or undefined,
     2  the template file cannot be opened for reading,
     3  failed to get file status information,
     4  the template file is not a regular file,
     5  an error is encountered while reading the template file,
     6  memory allication failed (not enough memory available),
     7  there is no line in the template that matches the input,
     8  invalid input specification Example: February 31 or a time is
        specified that can not be represented in a time_t (representing
    the time in seconds since 00:00:00 UTC, January 1, 1970) */
		memset(dateerrs, 0x00, sizeof(dateerrs));
		
		switch (getdate_err) {
		case 1: strncpy(dateerrs, "the DATEMSK environment variable is null or undefined,", sizeof(dateerrs)); break;
		case 2: strncpy(dateerrs, "the template file cannot be opened for reading,", sizeof(dateerrs)); break;
		case 3: strncpy(dateerrs, "failed to get file status information,", sizeof(dateerrs)); break;
		case 4: strncpy(dateerrs, "the template file is not a regular file,", sizeof(dateerrs)); break;
		case 5: strncpy(dateerrs, "an error is encountered while reading the template file,", sizeof(dateerrs)); break;
		case 6: strncpy(dateerrs, "memory allication failed (not enough memory available),", sizeof(dateerrs)); break;
		case 7: strncpy(dateerrs, "there is no line in the template that matches the input,", sizeof(dateerrs)); break;
		case 8: strncpy(dateerrs, "invalid input specification Example: February 31 or a time is\nspecified that can not be represented in a time_t (representing\nthe time in seconds since 00:00:00 UTC, January 1, 1970)", sizeof(dateerrs)); break;
		default: strncpy(dateerrs, "Unknown getdate_err error code", sizeof(dateerrs)); break;
		}
		
		printf("%s: strtm=getdate(argv[1]=%s): if (strtm!=NULL): else: getdate_err=%d:%s\n", self, argv[1], getdate_err, dateerrs);
	}
#else
	/* getdate() is not available on this OS platform !!! */
	printf("%s: getdate() is not available on this OS platform !!!\n", argv[0]);
#endif /*defined(HAVE_GETDATE)*/
	
	return 0;
}

program należy skompilować komendą make (jako argument należy podać plik Makefile zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile):
make clean all # system Linux
make -f Makefile clean all # system Linux
make -f Makefile.obsd clean all # system OpenBSD
make -f Makefile.fbsd clean all # system FreeBSD
make -f Makefile.sol clean all # system Solaris
make -f Makefile.beos clean all # system BeOS
make -f Makefile.win clean all # system Windows

a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/datetime/strptime
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/datetime/strptime <timestring> <timeformat>
Examples:
       DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "2001/02/03 04:05:06" "%Y/%m/%d %H:%M:%S"
       DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "2001-02-03 04:05:06" "%Y-%m-%d %H:%M:%S"
       DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "2013 Feb 03 04:05:06" "%Y %b %d %H:%M:%S"
       DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "Sun, 15 Sep 2013 05:02:12" "%a, %d %b %Y %H:%M:%S"

Contents /home/local/code/ansiccode/datetime/datemsk
----------------------------------------------------
%Y/%m/%d %H:%M:%S
%Y-%m-%d %H:%M:%S
%Y %b %d %H:%M:%S
%a, %d %b %Y %H:%M:%S

jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "2001/02/03 04:05:06" "%Y/%m/%d %H:%M:%S"
DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "2001-02-03 04:05:06" "%Y-%m-%d %H:%M:%S"
DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "2013 Feb 03 04:05:06" "%Y %b %d %H:%M:%S"
DATEMSK=/home/local/code/ansiccode/datetime/datemsk /home/local/code/ansiccode/datetime/strptime "Sun, 15 Sep 2013 05:02:12" "%a, %d %b %Y %H:%M:%S"
rezultat będzie zależny od podanych argumentów wywołania programu:
strptime: strptime(argv[1]=2001/02/03 04:05:06, argv[2]=%Y/%m/%d %H:%M:%S, strtm): datetime=2001/02/03 04:05:06
strptime: strtm=getdate(argv[1]=2001/02/03 04:05:06): if (strtm!=NULL): datetime=2001/02/03 04:05:06

strptime: strptime(argv[1]=2001-02-03 04:05:06, argv[2]=%Y-%m-%d %H:%M:%S, strtm): datetime=2001/02/03 04:05:06
strptime: strtm=getdate(argv[1]=2001-02-03 04:05:06): if (strtm!=NULL): datetime=2001/02/03 04:05:06

strptime: strptime(argv[1]=2013 Feb 03 04:05:06, argv[2]=%Y %b %d %H:%M:%S, strtm): datetime=2013/02/03 04:05:06
strptime: strtm=getdate(argv[1]=2013 Feb 03 04:05:06): if (strtm!=NULL): datetime=2013/02/03 04:05:06

strptime: strptime(argv[1]=Sun, 15 Sep 2013 05:02:12, argv[2]=%a, %d %b %Y %H:%M:%S, strtm): datetime=2013/09/15 05:02:12
strptime: strtm=getdate(argv[1]=Sun, 15 Sep 2013 05:02:12): if (strtm!=NULL): datetime=2013/09/15 05:02:12



#top time


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji time() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji time() jest następująca:
/* Return the current time and put it in *TIMER if TIMER is not NULL.  */
extern time_t time (time_t *__timer) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja time() zwraca czas (en.wiki:timestamp) jaki upłynął od początku epoki Unixa (od 1 stycznia 1970 00:00:00) mierzony w sekundach. Jeśli argument __timer przekazany jako wskaźnik nie jest NULL zwracany czas jest również umieszczany w argumencie wywołania.

Argumenty:
time_t *__timer - argument wywołania przekazany jako wskaźnik, w który jeśli nie jest NULL umieszczany jest również zwracany czas.

Zwracana wartość:
time_t - czas jaki upłynął od początku epoki Unixa (od 1 stycznia 1970 00:00:00) mierzony w sekundach.



#top timegm


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji timegm() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji timegm() jest następująca:
/* Like `mktime', but for TP represents Universal Time, not local time.  *:
extern time_t timegm (struct tm *__tp) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja timegm() podobnie jak funkcja mktime() zwraca czas w postaci typu time_t dla czasu podanego jako argument w postaci wskaźnika do struktury struct tm jednakże w odróżnieniu od funkcji mktime() zwracany czas jest w Coordinated Universal Time (UTC). Funkcja timegm() wykonuje operację odwrotną do funkcji gmtime()

Argumenty:
struct tm *__tp - wskaźnik do struktury zawierającej czas, który zostanie zwrócony w postaci typu time_t w Coordinated Universal Time (UTC).

Zwracana wartość:
time_t - czas w postaci typu time_t w Coordinated Universal Time (UTC) skorelowany z czasem przekazanym jako argment wywołania.



#top timelocal


Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org

Deklaracja funkcji time() znajduje się w pliku nagłówkowym time.h.
Deklaracja funkcji time() jest następująca:
/* Another name for `mktime'.  *:
extern time_t timelocal (struct tm *__tp) __THROW;

Powiązane:
asctime(), ctime(), gettimeofday(), gmtime(), mktime(), localtime(), strftime(), time(), timegm(), timelocal(),

Opis:
Funkcja timelocal() podobnie jak funkcja mktime() zwraca czas w postaci typu time_t dla czasu podanego jako argument w postaci wskaźnika do struktury struct tm. Funkcja timelocal() wykonuje operację odwrotną do funkcji localtime().

Argumenty:
struct tm *__tp - wskaźnik do struktury zawierającej czas, który zostanie zwrócony w postaci typu time_t.

Zwracana wartość:
time_t - czas w postaci typu time_t skorelowany z czasem przekazanym jako argment wywołania.





Zmodyfikowany ostatnio: 2015/10/01 19:46:11 (8 lat temu), textsize: 103 kB, htmlsize: 145 kB

Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników