SetTimeZone() public method

public SetTimeZone ( TimeZoneInfo timeZone ) : void
timeZone System.TimeZoneInfo
return void
Example #1
0
		private string Iso(PersonIdent id)
		{
			SimpleDateFormat fmt;
			fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
			fmt.SetTimeZone(id.GetTimeZone());
			return fmt.Format(id.GetWhen());
		}
Example #2
0
 public virtual DateTime? GetDate(int tagType, [CanBeNull] TimeZoneInfo timeZone)
 {
     object o = GetObject(tagType);
     if (o == null)
     {
         return null;
     }
     if (o is DateTime)
     {
         return (DateTime)o;
     }
     if (o is string)
     {
         // This seems to cover all known Exif date strings
         // Note that "    :  :     :  :  " is a valid date string according to the Exif spec (which means 'unknown date'): http://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif/datetimeoriginal.html
         string[] datePatterns = new string[] { "yyyy:MM:dd HH:mm:ss", "yyyy:MM:dd HH:mm", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm" };
         string dateString = (string)o;
         foreach (string datePattern in datePatterns)
         {
             try
             {
                 DateFormat parser = new SimpleDateFormat(datePattern);
                 if (timeZone != null)
                 {
                     parser.SetTimeZone(timeZone);
                 }
                 return parser.Parse(dateString);
             }
             catch (ParseException)
             {
             }
         }
     }
     // simply try the next pattern
     return null;
 }
Example #3
0
		public override string ToString()
		{
			StringBuilder r = new StringBuilder();
			SimpleDateFormat dtfmt;
			dtfmt = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy Z", CultureInfo.InvariantCulture
				);
			dtfmt.SetTimeZone(GetTimeZone());
			r.Append("PersonIdent[");
			r.Append(GetName());
			r.Append(", ");
			r.Append(GetEmailAddress());
			r.Append(", ");
			r.Append(dtfmt.Format(Sharpen.Extensions.ValueOf(when)));
			r.Append("]");
			return r.ToString();
		}
Example #4
0
		private static string HttpNow()
		{
			string tz = "GMT";
			SimpleDateFormat fmt;
			fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture
				);
			fmt.SetTimeZone(Sharpen.Extensions.GetTimeZone(tz));
			return fmt.Format(new DateTime()) + " " + tz;
		}