Mercurial > projects > dil
view src/dil/Time.d @ 810:525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Added options -I, -release and -unittest to the compile command.
Tidied main.d up a bit.
Renamed start() methods of SemanticPass1 and 2 to run().
Moved function findModuleFilePath() to class ModuleManager.
Added msg CouldntLoadModule. Corrected two others.
Added member semanticPass to class Module.
Implemented visit(ImportDeclaration) in SemanticPass1.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 11 Mar 2008 02:48:01 +0100 |
parents | bcb74c9b895c |
children |
line wrap: on
line source
/++ Author: Aziz Köksal License: GPL3 +/ module dil.Time; import tango.stdc.time : time_t, time, ctime; import tango.stdc.string : strlen; /// Some convenience functions for dealing with C's time functions. struct Time { static: /// Returns the current date as a string. char[] toString() { time_t time_val; .time(&time_val); char* str = ctime(&time_val); // ctime returns a pointer to a static array. char[] timeStr = str[0 .. strlen(str)-1]; // -1 removes trailing '\n'. return timeStr.dup; } /// Returns the time of timeStr: hh:mm:ss char[] time(char[] timeStr) { return timeStr[11..19]; } /// Returns the month and day of timeStr: Mmm dd char[] month_day(char[] timeStr) { return timeStr[4..10]; } /// Returns the year of timeStr: yyyy char[] year(char[] timeStr) { return timeStr[20..24]; } }