Esempio n. 1
0
        private long?WriteAdj(CsnAdjustment y, Writer w, long adjType, long ttType)
        {
            long rc1 = WriteTrTime(y.TransitionStart, w, ttType);
            long rc2 = WriteTrTime(y.TransitionEnd, w, ttType);

            return(w.WriteInstance(adjType).W(y.StartDate).W(y.EndDate).W(y.DaylightDeltaHours).WRef(rc1).WRef(rc2).Current);
        }
Esempio n. 2
0
 private void Serialize(CsnAdjustment adj, JsonTextWriter json)
 {
     json.WriteStartObject();
     json.WritePropertyName(this.names[8]);
     json.WriteValue(adj.StartDate);
     json.WritePropertyName(this.names[9]);
     json.WriteValue(adj.EndDate);
     json.WritePropertyName(this.names[10]);
     json.WriteValue(adj.DaylightDeltaHours);
     Serialize(this.names[11], adj.TransitionStart, json);
     Serialize(this.names[12], adj.TransitionEnd, json);
     json.WriteEndObject();
 }
Esempio n. 3
0
        public void Serialize(CsnTimeZones ctzs, StreamWriter sw)
        {
            Writer w = new Writer(sw);
            // typedefs
            long ttType  = w.WriteTypeDef("TransitionTime", "IsFixedDateRule", "Day", "Month", "TimeOfDay", "Week", "DayOfWeek").Current;
            long adjType = w.WriteTypeDef("Adjustment", "StartDate", "EndDate", "DaylightDeltaHours", "TransitionStart", "TransitionEnd").Current;
            long tzType  = w.WriteTypeDef("TimeZone", "Id", "DisplayName", "DaylightName", "StandardName", "HasDst", "UtcOffsetHours", "Adjustments").Current;
            long tzsType = w.WriteTypeDef("TimeZones", "AllTimeZones").Current;

            int tzLen = ctzs.AllTimeZones.Length;

            long?[] rcTzsArr = new long?[tzLen];
            for (int tzCtr = 0; tzCtr < tzLen; tzCtr++)
            {
                CsnTimeZone ctz      = ctzs.AllTimeZones[tzCtr];
                long?       rcAdjArr = null;
                if (ctz.Adjustments != null)
                {
                    int adjLen = ctz.Adjustments.Length;
                    if (adjLen > 0)
                    {
                        long?[] arrAdjs = new long?[adjLen];
                        for (int adjCtr = 0; adjCtr < adjLen; adjCtr++)
                        {
                            CsnAdjustment adj       = ctz.Adjustments[adjCtr];
                            long?         rcTtStart = this.WriteTrTime(adj.TransitionStart, w, ttType);
                            long?         rcTtEnd   = this.WriteTrTime(adj.TransitionEnd, w, ttType);
                            arrAdjs[adjCtr] = w.WriteInstance(adjType).W(adj.StartDate).W(adj.EndDate).W(adj.DaylightDeltaHours).WRef(rcTtStart).WRef(rcTtEnd).Current;
                        }

                        rcAdjArr = w.WriteArray().WRef(arrAdjs).Current;
                    }
                }
                rcTzsArr[tzCtr] = w.WriteInstance(tzType).W(ctz.Id).W(ctz.DisplayName).W(ctz.DaylightName).W(ctz.StandardName).W(ctz.HasDst).W(ctz.UtcOffsetHours).WRef(rcAdjArr).Current;
            }
            long rc = w.WriteArray().WRef(rcTzsArr).Current;

            w.WriteInstance(tzsType).WRef(rc);
            sw.Flush();
        }