Unix Epoch Timestamp zu AppleScript Datum

Ich wollte für ein Script Unix-Zeitstempel in ein Apple-Script-Datum konvertieren, und fand bei einer Suche diesen QuelleCode, der anscheinend nur unter englischen System funktioniert.... Nun, deshalb habe ich mir meine eigene AppleScript Routine geschrieben, die mir einfachen Mitteln einen Epoch-Zeitstempel in ein Applescript-Datum umwandelt:
Code zum markieren einmal anklicken

set einEpochString to do shell script "perl -e 'print time.\"\\n\";'" -- current epoch time as string


epoch2AppleScriptDate(einEpochString)


on epoch2AppleScriptDate(epoch_string)

set h to do shell script "date -r " & epoch_string & " \"+%Y %m %d %H %M %S\""

set mydate to current date

set year of mydate to (word 1 of h as integer)

set month of mydate to (word 2 of h as integer)

set day of mydate to (word 3 of h as integer)

set hours of mydate to (word 4 of h as integer)

set minutes of mydate to (word 5 of h as integer)

set seconds of mydate to (word 6 of h as integer)

return mydate

end epoch2AppleScriptDate

Update (10.11.2010)

Und heute wollte ich unbedingt via AppleScript einen Epoch-Zeitstempel erzeugen und fand hier folgendes:
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

set nowSeconds to ((current date) - (date ("1/1/1970")) - (time to GMT)) as miles as string

This entry was posted in AppleScript and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


7 × = twenty eight

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...