public static MutableString /*!*/ Dump(RubyContext /*!*/ context, RubyTime /*!*/ self, [Optional] int depth) { if (self.DateTime.Year < 1900 || self.DateTime.Year > 2038) { throw RubyExceptions.CreateTypeError("unable to marshal time"); } DateTime value = RubyTime.ToUniversalTime(self.DateTime); // Little Endian // 32 | 32 | // minute:6|second:6|usec:20|1|utc:1|year:16|month:4|day:5|hour:5| uint dword1 = self.Kind == DateTimeKind.Utc ? 0xC0000000 : 0x80000000; dword1 |= (unchecked ((uint)(value.Year - 1900)) << 14); dword1 |= (unchecked ((uint)(value.Month - 1)) << 10); dword1 |= ((uint)value.Day << 5); dword1 |= ((uint)value.Hour); uint dword2 = 0; dword2 |= ((uint)value.Minute << 26); dword2 |= ((uint)value.Second << 20); dword2 |= ((uint)((value.Ticks % 10000000) / 10)); MemoryStream buf = new MemoryStream(8); RubyEncoder.Write(buf, dword1, !BitConverter.IsLittleEndian); RubyEncoder.Write(buf, dword2, !BitConverter.IsLittleEndian); return(MutableString.CreateBinary(buf.ToArray())); }
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 /*!*/ GetUTC(RubyTime /*!*/ self) { return(new RubyTime(self.ToUniversalTime())); }
public static RubyTime /*!*/ SwitchToUtc(RubyTime /*!*/ self) { self.SetDateTime(self.ToUniversalTime()); return(self); }