public static RubyTime /*!*/ InitializeCopy(RubyTime /*!*/ self, [NotNull] RubyTime /*!*/ other) { self.SetDateTime(other.DateTime); return(self); }
public static int DayOfYear(RubyTime self) { return(self.DateTime.DayOfYear); }
public static MutableString /*!*/ FormatTime(RubyContext /*!*/ context, RubyTime /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ format) { MutableString result = MutableString.CreateMutable(format.Encoding); bool inFormat = false; var charEnum = format.GetCharacters(); while (charEnum.MoveNext()) { var character = charEnum.Current; int c = character.IsValid ? character.Value : -1; if (!inFormat) { if (c == '%') { inFormat = true; } else { result.Append(character); } continue; } inFormat = false; string dateTimeFormat = null; switch (c) { case '%': result.Append('%'); break; case 'a': dateTimeFormat = "ddd"; break; case 'A': dateTimeFormat = "dddd"; break; case 'b': dateTimeFormat = "MMM"; break; case 'B': dateTimeFormat = "MMMM"; break; case 'c': dateTimeFormat = "g"; break; case 'd': dateTimeFormat = "dd"; break; case 'D': dateTimeFormat = "MM/dd/yy"; break; case 'e': { // Day of the month, blank-padded ( 1..31) int day = self.DateTime.Day; if (day < 10) { result.Append(' '); } result.Append(day.ToString(CultureInfo.InvariantCulture)); break; } case 'H': dateTimeFormat = "HH"; break; case 'I': dateTimeFormat = "hh"; break; case 'j': result.AppendFormat("{0:000}", self.DateTime.DayOfYear); break; case 'l': { int hour = self.DateTime.Hour; if (hour == 0) { hour = 12; } else if (hour > 12) { hour -= 12; } if (hour < 10) { result.Append(' '); } result.Append(hour.ToString(CultureInfo.InvariantCulture)); break; } case 'm': dateTimeFormat = "MM"; break; case 'M': dateTimeFormat = "mm"; break; case 'N': dateTimeFormat = "fffffff00"; break; case 'p': dateTimeFormat = "tt"; break; case 'S': dateTimeFormat = "ss"; break; case 'T': dateTimeFormat = "HH:mm:ss"; break; case 'U': FormatDayOfWeek(result, self.DateTime, 7); break; case 'W': FormatDayOfWeek(result, self.DateTime, 8); break; case 'w': result.Append(((int)self.DateTime.DayOfWeek).ToString(CultureInfo.InvariantCulture)); break; case 'x': dateTimeFormat = "d"; break; case 'X': dateTimeFormat = "t"; break; case 'y': dateTimeFormat = "yy"; break; case 'Y': dateTimeFormat = "yyyy"; break; case 'Z': dateTimeFormat = "%K"; break; case 'z': if (context.RubyOptions.Compatibility > RubyCompatibility.Ruby186) { result.Append(self.FormatUtcOffset()); } else { result.Append(RubyTime.GetCurrentZoneName()); } break; default: result.Append('%'); result.Append(character); break; } if (dateTimeFormat != null) { result.Append(self.ToString(dateTimeFormat, CultureInfo.InvariantCulture)); } } if (inFormat) { if (context.RubyOptions.Compatibility > RubyCompatibility.Ruby186) { return(result.Append('%')); } return(MutableString.CreateEmpty()); } return(result); }
public static int Second(RubyTime self) { return(self.DateTime.Second); }
public static int Month(RubyTime self) { return(self.DateTime.Month); }
public static object Offset(RubyTime /*!*/ self) { return(Protocols.Normalize(self.GetCurrentZoneOffset().Ticks / 10000000)); }
public static int Hour(RubyTime self) { return(self.DateTime.Hour); }
public static double SubtractTime(RubyTime /*!*/ self, [NotNull] RubyTime /*!*/ other) { return((self - other).TotalSeconds); }
public static double SubtractTime(RubyTime /*!*/ self, DateTime other) { return((self.DateTime - other).TotalSeconds); }
public static RubyTime /*!*/ SuccessiveSecond(RubyTime /*!*/ self) { return(AddSeconds(self, 1.0)); }
public static RubyTime /*!*/ AddSeconds(RubyTime /*!*/ self, [NotNull] RubyTime /*!*/ seconds) { throw RubyExceptions.CreateTypeError("time + time?"); }
public static RubyTime /*!*/ Create(RubyClass /*!*/ self, int seconds, int microseconds) { return(new RubyTime(RubyTime.ToLocalTime(RubyTime.Epoch.AddTicks(RubyTime.ToTicks(seconds, microseconds))))); }
public static RubyTime /*!*/ Create(RubyClass /*!*/ self, double seconds) { return(new RubyTime(RubyTime.ToLocalTime(RubyTime.AddSeconds(RubyTime.Epoch, seconds)))); }
public static RubyTime /*!*/ Create(RubyClass /*!*/ self, [NotNull] RubyTime /*!*/ other) { return(new RubyTime(other.Ticks, other.Kind)); }
public static bool IsUts(RubyTime /*!*/ self) { return(self.DateTime.Kind == DateTimeKind.Utc); }
public static int CompareTo(RubyTime /*!*/ self, [NotNull] RubyTime /*!*/ other) { return(self.CompareTo(other)); }
public static object IsDst(RubyContext /*!*/ context, RubyTime /*!*/ self) { return(self.GetCurrentDst(context)); }
public static object CompareSeconds(RubyTime /*!*/ self, object other) { return(null); }
public static RubyTime /*!*/ GetUTC(RubyTime /*!*/ self) { return(new RubyTime(self.ToUniversalTime())); }
public static bool Eql(RubyTime /*!*/ self, [NotNull] RubyTime /*!*/ other) { return(self.Equals(other)); }
public static int Minute(RubyTime self) { return(self.DateTime.Minute); }
public static bool Eql(RubyTime /*!*/ self, object other) { return(false); }
public static int GetMicroSeconds(RubyTime self) { return(self.Microseconds); }
public static int GetHash(RubyTime /*!*/ self) { return(self.GetHashCode()); }
public static int Day(RubyTime self) { return(self.DateTime.Day); }
public static RubyTime /*!*/ SwitchToUtc(RubyTime /*!*/ self) { self.SetDateTime(self.ToUniversalTime()); return(self); }
public static int DayOfWeek(RubyTime /*!*/ self) { return((int)self.DateTime.DayOfWeek); }
public static RubyTime /*!*/ ToLocalTime(RubyTime /*!*/ self) { self.SetDateTime(self.ToLocalTime()); return(self); }
public static int UpdateTimes(RubyClass /*!*/ self, [NotNull] RubyTime /*!*/ accessTime, [NotNull] RubyTime /*!*/ modifiedTime, [NotNull] MutableString /*!*/ path) { string strPath = self.Context.DecodePath(path); FileInfo info = new FileInfo(strPath); if (!info.Exists) { throw RubyExceptions.CreateENOENT("No such file or directory - {0}", strPath); } info.LastAccessTimeUtc = accessTime.ToUniversalTime(); info.LastWriteTimeUtc = modifiedTime.ToUniversalTime(); return(1); }
public static RubyTime /*!*/ Reinitialize(RubyTime /*!*/ self) { self.DateTime = RubyTime.GetCurrentLocalTime(); return(self); }