Tweets from pichat
| Two songs from the year I created my first web sites. http://t.co/8eHrOA9K + http://t.co/AuWb2etI #video #retro About 1 day, 1 hour ago from pichat (Mark Seuffert) |
Tweets from 600infos
| I HAVE NYANED FOR 888.4 SECONDS! http://t.co/JQYOZebv via @nyannyancat About 1 week, 5 days ago from 600infos (Wolf) |
Trace: » Creates a colored Banner Text for Pichat » simple css layout » new_colorscheme_b65 » Overview of Website integrations » Pichat als Service (de) » CMD Function DateTime
You are here: Pichat Wiki (en) » Snippets » CMD Function DateTime
Table of Contents
CMD Function DateTime
datetime
:datetime DateStr TimeStr -- converts a date string to julian day number with respect to regional date format :: -- and returns single Time values :: -- if no option is available the actual Date and Time is used :: -- DateStr [in,opt] - date string, e.g. "03/31/2006" or "Fri 03/31/2006" or "31.3.2006" :: -- TimeStr [in,opt] - date string, e.g. "12:34:56.78" REM will be modified soon
jdate
:jdate JD DateStr -- converts a date string to julian day number with respect to regional date format
:: -- JD [out,opt] - julian days
:: -- DateStr [in,opt] - date string, e.g. "03/31/2006" or "Fri 03/31/2006" or "31.3.2006"
:$reference http://groups.google.com/group/alt.msdos.batch.nt/browse_frm/thread/a0c34d593e782e94/50ed3430b6446af8#50ed3430b6446af8
:$created 20060101 :$changed 20090328 :$categories DateAndTime
:$source http://www.dostips.com
SETLOCAL
set DateStr=%~2&if "%~2"=="" set DateStr=%date%
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
for /f "tokens=1-3 delims=/.- " %%A in ("%DateStr:* =%") do (
set %%a=%%A&set %%b=%%B&set %%c=%%C))
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
if %yy% LSS 100 set /a yy+=2000 &rem Adds 2000 to two digit years
set /a JD=dd-32075+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/12*12)/12-3*((yy+4900+(mm-14)/12)/100)/4
ENDLOCAL & IF "%~1" NEQ "" (SET %~1=%JD%) ELSE (echo.%JD%)
EXIT /b
dayOfYear
:dayOfYear JD DateStr -- returns the day of the year, i.e. 1 for 1/1/2008, 266 for 12/31/2008
:: -- day [out,opt] - variable name to store resulting day of the year
:: -- DateStr [in,opt] - date string, e.g. "3/31/2006" or "Fri 03/31/2006" or "31.3.2006", or omit form current date
:$reference http://groups.google.com/group/alt.msdos.batch.nt/browse_frm/thread/a0c34d593e782e94/50ed3430b6446af8#50ed3430b6446af8
:$created 20080612 :$changed 20080612 :$categories DateAndTime
:$source http://www.dostips.com
SETLOCAL
set "DateStr=%~2"&if "%~2"=="" set "DateStr=%date%"
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
for /f "tokens=1-3 delims=/.- " %%A in ("%DateStr:* =%") do (
set %%a=%%A&set %%b=%%B&set %%c=%%C))
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
set /a JD=dd-32075+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/12*12)/12-3*((yy+4900+(mm-14)/12)/100)/4
set /a "yy=10000%yy% %%10000,mm=1,dd=1"
set /a JD-=-1+dd-32075+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/12*12)/12-3*((yy+4900+(mm-14)/12)/100)/4
ENDLOCAL & IF "%~1" NEQ "" (SET %~1=%JD%) ELSE (echo.%JD%)
EXIT /b
Unique
:Unique ret -- returns a 16 digits unique string based on a date-time-stamp, YYYYMMDDhhmmsscc
:: -- ret [out,opt] - unique string
:$created 20060101 :$changed 20080219 :$categories StringOperation,DateAndTime
::modified by Mark Wolfgruber 20110414 : if less than 10 adding leading zero for %yy%, %mm% and %dd%
::modified for german enviroment by Mark Wolfgruber 20101129
:$source http://www.dostips.com
SETLOCAL
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
set %%a=%%A&set %%b=%%B&set %%c=%%C))
if DEFINED jj set yy=%jj%
if DEFINED tt set dd=%tt%
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
if %yy% LEQ 9 set mm=0%yy%
if %mm% LEQ 9 set mm=0%mm%
if %dd% LEQ 9 set dd=0%dd%
for /f "tokens=1-4 delims=:., " %%A in ("%time: =0%") do @set UNIQUE=%yy%%mm%%dd%%%A%%B%%C%%D
ENDLOCAL & IF "%~1" NEQ "" (SET %~1=%UNIQUE%) ELSE echo.%UNIQUE%
EXIT /b