D2 phobos std.date question

Sam Hu samhudotsamhu at gmail.com
Tue Jul 14 18:55:53 PDT 2009


Stewart Gordon Wrote:

> 
> Read the source of std.date and see for yourself.  If it's getting it 
> wrong, it suggests either your system is misconfigured or you're using 
> it wrongly.  But since you still haven't posted your code, I still can't 
> comment further.
> 
> Stewart.

Thank you so much again.
Actually I just tried the example based on the one inside the std.date source:
/*************************************
 * Converts UTC time into a text string of the form:
 * "Www Mmm dd hh:mm:ss GMT+-TZ yyyy".
 * For example, "Tue Apr 02 02:04:57 GMT-0800 1996".
 * If time is invalid, i.e. is d_time_nan,
 * the string "Invalid date" is returned.
 *
 * Example:
 * ------------------------------------
 */
  d_time lNow;
  string lNowString;//char[] lNowString;

  // Grab the date and time relative to UTC
  lNow = std.date.getUTCtime();
  // Convert this into the local date and time for display.
  lNowString = std.date.toString(lNow);
 /* ------------------------------------
 */
//And add testing below:
d_time localTime=std.date.UTCtoLocalTime(lNow);
string localTimeString=std.date.toString(localTime);

writefln(lNowString);
writefln(localTimeString);

===========
output:
===========
Wed Jul 15 01:47:42 GMT+0000 2009
Wed Jul 15 01:47:42 GMT+0000 2009





More information about the Digitalmars-d-learn mailing list