コード例 #1
0
ファイル: TimeZoneInfo.Unix.cs プロジェクト: justinvp/corert
        private static void TZif_ParseRaw(Byte[] data, out TZifHead t, out DateTime[] dts, out Byte[] typeOfLocalTime, out TZifType[] transitionType,
                                          out String zoneAbbreviations, out Boolean[] StandardTime, out Boolean[] GmtTime)
        {
            // initialize the out parameters in case the TZifHead ctor throws
            dts = null;
            typeOfLocalTime = null;
            transitionType = null;
            zoneAbbreviations = String.Empty;
            StandardTime = null;
            GmtTime = null;

            // read in the 44-byte TZ header containing the count/length fields
            //
            t = new TZifHead(data, 0);
            int index = TZifHead.Length;

            // initialize the containers for the rest of the TZ data
            dts = new DateTime[t.TimeCount];
            typeOfLocalTime = new Byte[t.TimeCount];
            transitionType = new TZifType[t.TypeCount];
            zoneAbbreviations = String.Empty;
            StandardTime = new Boolean[t.TypeCount];
            GmtTime = new Boolean[t.TypeCount];


            // read in the 4-byte UTC transition points and convert them to Windows
            //
            for (int i = 0; i < t.TimeCount; i++)
            {
                int unixTime = TZif_ToInt32(data, index);
                dts[i] = TZif_UnixTimeToWindowsTime(unixTime);
                index += 4;
            }

            // read in the Type Indices; there is a 1:1 mapping of UTC transition points to Type Indices
            // these indices directly map to the array index in the transitionType array below
            //
            for (int i = 0; i < t.TimeCount; i++)
            {
                typeOfLocalTime[i] = data[index];
                index += 1;
            }

            // read in the Type table.  Each 6-byte entry represents
            // {UtcOffset, IsDst, AbbreviationIndex}
            // 
            // each AbbreviationIndex is a character index into the zoneAbbreviations string below
            //
            for (int i = 0; i < t.TypeCount; i++)
            {
                transitionType[i] = new TZifType(data, index);
                index += 6;
            }

            // read in the Abbreviation ASCII string.  This string will be in the form:
            // "PST\0PDT\0PWT\0\PPT"
            //
            System.Text.Encoding enc = new System.Text.UTF8Encoding();
            zoneAbbreviations = enc.GetString(data, index, (int)t.CharCount);
            index += (int)t.CharCount;

            // skip ahead of the Leap-Seconds Adjustment data.  In a future release, consider adding
            // support for Leap-Seconds
            //
            index += (int)(t.LeapCount * 8); // skip the leap second transition times

            // read in the Standard Time table.  There should be a 1:1 mapping between Type-Index and Standard
            // Time table entries.
            //
            // TRUE     =     transition time is standard time
            // FALSE    =     transition time is wall clock time
            // ABSENT   =     transition time is wall clock time
            //
            for (int i = 0; i < t.IsStdCount && i < t.TypeCount && index < data.Length; i++)
            {
                StandardTime[i] = (data[index++] != 0);
            }

            // read in the GMT Time table.  There should be a 1:1 mapping between Type-Index and GMT Time table
            // entries.
            //
            // TRUE     =     transition time is UTC
            // FALSE    =     transition time is local time
            // ABSENT   =     transition time is local time
            //
            for (int i = 0; i < t.IsGmtCount && i < t.TypeCount && index < data.Length; i++)
            {
                GmtTime[i] = (data[index++] != 0);
            }
        }
コード例 #2
0
        private static void TZif_ParseRaw(Byte[] data, out TZifHead t, out DateTime[] dts, out Byte[] typeOfLocalTime, out TZifType[] transitionType,
                                          out String zoneAbbreviations, out Boolean[] StandardTime, out Boolean[] GmtTime)
        {
            // initialize the out parameters in case the TZifHead ctor throws
            dts               = null;
            typeOfLocalTime   = null;
            transitionType    = null;
            zoneAbbreviations = String.Empty;
            StandardTime      = null;
            GmtTime           = null;

            // read in the 44-byte TZ header containing the count/length fields
            //
            t = new TZifHead(data, 0);
            int index = TZifHead.Length;

            // initialize the containers for the rest of the TZ data
            dts               = new DateTime[t.TimeCount];
            typeOfLocalTime   = new Byte[t.TimeCount];
            transitionType    = new TZifType[t.TypeCount];
            zoneAbbreviations = String.Empty;
            StandardTime      = new Boolean[t.TypeCount];
            GmtTime           = new Boolean[t.TypeCount];


            // read in the 4-byte UTC transition points and convert them to Windows
            //
            for (int i = 0; i < t.TimeCount; i++)
            {
                int unixTime = TZif_ToInt32(data, index);
                dts[i] = TZif_UnixTimeToWindowsTime(unixTime);
                index += 4;
            }

            // read in the Type Indices; there is a 1:1 mapping of UTC transition points to Type Indices
            // these indices directly map to the array index in the transitionType array below
            //
            for (int i = 0; i < t.TimeCount; i++)
            {
                typeOfLocalTime[i] = data[index];
                index += 1;
            }

            // read in the Type table.  Each 6-byte entry represents
            // {UtcOffset, IsDst, AbbreviationIndex}
            //
            // each AbbreviationIndex is a character index into the zoneAbbreviations string below
            //
            for (int i = 0; i < t.TypeCount; i++)
            {
                transitionType[i] = new TZifType(data, index);
                index            += 6;
            }

            // read in the Abbreviation ASCII string.  This string will be in the form:
            // "PST\0PDT\0PWT\0\PPT"
            //
            System.Text.Encoding enc = new System.Text.UTF8Encoding();
            zoneAbbreviations = enc.GetString(data, index, (int)t.CharCount);
            index            += (int)t.CharCount;

            // skip ahead of the Leap-Seconds Adjustment data.  In a future release, consider adding
            // support for Leap-Seconds
            //
            index += (int)(t.LeapCount * 8); // skip the leap second transition times

            // read in the Standard Time table.  There should be a 1:1 mapping between Type-Index and Standard
            // Time table entries.
            //
            // TRUE     =     transition time is standard time
            // FALSE    =     transition time is wall clock time
            // ABSENT   =     transition time is wall clock time
            //
            for (int i = 0; i < t.IsStdCount && i < t.TypeCount && index < data.Length; i++)
            {
                StandardTime[i] = (data[index++] != 0);
            }

            // read in the GMT Time table.  There should be a 1:1 mapping between Type-Index and GMT Time table
            // entries.
            //
            // TRUE     =     transition time is UTC
            // FALSE    =     transition time is local time
            // ABSENT   =     transition time is local time
            //
            for (int i = 0; i < t.IsGmtCount && i < t.TypeCount && index < data.Length; i++)
            {
                GmtTime[i] = (data[index++] != 0);
            }
        }
コード例 #3
0
ファイル: TimeZoneInfo.Tachyon.cs プロジェクト: Rew/runtime
 private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dts, out byte[] typeOfLocalTime, out TZifType[] transitionType,
                                   out string zoneAbbreviations, out bool[] StandardTime, out bool[] GmtTime, out string?futureTransitionsPosixFormat)
 {
     throw new NotImplementedException();
 }