Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considèrerons que vous acceptez l'utilisation des cookies. J'ai compris ! ou En savoir plus !.
banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

Printemps des cartes 2024

#1 Wed 12 December 2007 10:48

LASGOUZES
Participant assidu
Date d'inscription: 6 Mar 2006
Messages: 169

Convertir date de modification des fichiers (file mtime) en JJMMAAAA

Bonjour,

L'appel à TCLCaller permet de récupérer la date de modification d'un fichier (file mtime).

Par contre comment convertir cette date en JJMMAAAA.

Eventuellement comment réaliser la même opération en python.

Cordialement,

Hors ligne

 

#2 Wed 12 December 2007 11:49

MatteoA
Participant actif
Lieu: Montpellier
Date d'inscription: 26 Dec 2006
Messages: 121
Site web

Re: Convertir date de modification des fichiers (file mtime) en JJMMAAAA

Bonjour,

En TCL, vous pouvez utiliser la commande "clock format" pour convertir votre date format unix en date plus lisible.

La syntaxe est :
clock format variable -format %
où % va indiquer le type d'affichage de la date que vous souhaitez.

Par exemple :
set var [file mtime fichier.xxx]   <--  extrait la date du fichier "fichier.xxx" au format Unix
set  var2 [clock format $var -format %D]  <-- convertit la date au format %D c'est à dire MM/DD/YY
puts $var2  <--  affiche le résultat


Vous souhaitez un affichage de type JJMMAAAA, vous devez donc utiliser %d%m%Y ce qui donne dans notre exemple :
set  var2 [clock format $var -format %d%m%Y]

Vous pouvez extraire bien d'autres formats/informations :

%a     Abbreviated weekday name (Mon, Tue, etc.).
%A    Full weekday name (Monday, Tuesday, etc.).
%b    Abbreviated month name (Jan, Feb, etc.).
%B    Full month name.
%c    Locale specific date and time. The format for date and time in the default "C" locale on Unix/Mac is "%a %b %d %H:%M:%S %Y". On Windows, this value is the locale specific long date and time, as specified in the Regional Options control panel settings.
%C    First two digits of the four-digit year (19 or 20).
%d    Day of month (01 - 31).
%D    Date as %m/%d/%y.
%e    Day of month (1 - 31), no leading zeros.
%g    The ISO8601 year number corresponding to the ISO8601 week (%V), expressed as a two-digit year-of-the-century, with leading zero if necessary.
%G    The ISO8601 year number corresponding to the ISO8601 week (%V), expressed as a four-digit number.
%h    Abbreviated month name.
%H    Hour in 24-hour format (00 - 23).
%I    Hour in 12-hour format (01 - 12).
%j    Day of year (001 - 366).
%k    Hour in 24-hour format, without leading zeros (0 - 23).
%l    Hour in 12-hour format, without leading zeros (1 - 12).
%m    Month number (01 - 12).
%M    Minute (00 - 59).
%n    Insert a newline.
%p    AM/PM indicator.
%r    Time in a locale-specific "meridian" format. The "meridian" format in the default "C" locale is "%I:%M:%S %p".
%R    Time as %H:%M.
%s    Count of seconds since the epoch, expressed as a decimal integer.
%S    Seconds (00 - 59).
%t    Insert a tab.
%T    Time as %H:%M:%S.
%u    Weekday number (Monday = 1, Sunday = 7).
%U    Week of year (00 - 52), Sunday is the first day of the week.
%V    Week of year according to ISO-8601 rules. Week 1 of a given year is the week containing 4 January.
%w    Weekday number (Sunday = 0, Saturday = 6).
%W    Week of year (00 - 52), Monday is the first day of the week.
%x    Locale specific date format. The format for a date in the default "C" locale for Unix/Mac is "%m/%d/%y". On Windows, this value is the locale specific short date format, as specified in the Regional Options control panel settings.
%X    Locale specific 24-hour time format. The format for a 24-hour time in the default "C" locale for Unix/Mac is "%H:%M:%S". On Windows, this value is the locale specific time format, as specified in the Regional Options control panel settings.
%y    Year without century (00 - 99).
%Y    Year with century (e.g. 1990)
%Z    Time zone name.

(Source des % : http://www.tcl.tk/man/tcl8.4/TclCmd/clock.htm#M47)

Cordialement,
M. Ambrosy.

Dernière modification par MatteoA (Wed 12 December 2007 12:09)


Geonov - Expertise et formations FME certifiées - Infrastructure - Formations SIG : #FME #PostgreSQL #PostGIS #QGIS
https://www.geonov.fr

Hors ligne

 

#3 Wed 12 December 2007 14:45

LASGOUZES
Participant assidu
Date d'inscription: 6 Mar 2006
Messages: 169

Re: Convertir date de modification des fichiers (file mtime) en JJMMAAAA

Merci beaucoup votre réponse est parfaite, recette appliquée avec succés.

Hors ligne

 

#4 Wed 12 December 2007 20:30

MatteoA
Participant actif
Lieu: Montpellier
Date d'inscription: 26 Dec 2006
Messages: 121
Site web

Re: Convertir date de modification des fichiers (file mtime) en JJMMAAAA

LASGOUZES a écrit:

Merci beaucoup votre réponse est parfaite, recette appliquée avec succés.


C'est avec plaisir. Bonne continuation avec FME.


Geonov - Expertise et formations FME certifiées - Infrastructure - Formations SIG : #FME #PostgreSQL #PostGIS #QGIS
https://www.geonov.fr

Hors ligne

 

Pied de page des forums

Powered by FluxBB