Skip to content

Instantly share code, notes, and snippets.

@mrdaemon
Created January 30, 2011 18:31
Show Gist options
  • Save mrdaemon/803107 to your computer and use it in GitHub Desktop.
Save mrdaemon/803107 to your computer and use it in GitHub Desktop.
Shit example to parse the output of date
@echo off
:: $Id: env_universaldate.cmd 1986 2006-12-06 20:36:59Z gauthiera $
:: Librarie pour generation de date Universelle
::
:: ATTENTION: La date et le nom des variables
:: sont differents selon la langue du systeme
:: d'exploitation:
:: Francais: %jj% %mm% %aa%
:: Anglais: %mm% %dd% %yy%
::
set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
if "%$d1:~0,1%" GTR "9" set $tok=2-4
for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
set %%x=%%u
set %%y=%%v
set %%z=%%w
set $d1=
set $tok=))
if defined jj goto FRENCH
if defined dd goto ENGLISH
echo WARNING: Impossible de trouver la langue du systeme?
echo Contactez le support informatique avant de continuer.
pause
:ENGLISH
set OS_LANG=1
GOTO :EOF
:FRENCH
set OS_LANG=2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment