コード例 #1
0
        public Timezone(JObject json)
        {
            this.status = json.GetValue("status").ToObject <int>();

            JToken token   = json.GetValue("message");
            String message = token != null?token.ToObject <String>() : null;

            if (this.status != 200 || message != null)
            {
                this.message = message;
            }
            else
            {
                token         = json.GetValue("timezone");
                this.timezone = token != null?token.ToObject <String>() : null;

                token = json.GetValue("timezone_offset");
                this.timezoneOffset = token != null?token.ToObject <Double>() : 0.0;

                token     = json.GetValue("date");
                this.date = token != null?token.ToObject <String>() : null;

                token         = json.GetValue("date_time");
                this.dateTime = token != null?token.ToObject <String>() : null;

                token            = json.GetValue("date_time_txt");
                this.dateTimeTxt = token != null?token.ToObject <String>() : null;

                token            = json.GetValue("date_time_wti");
                this.dateTimeWti = token != null?token.ToObject <String>() : null;

                token            = json.GetValue("date_time_ymd");
                this.dateTimeYmd = token != null?token.ToObject <String>() : null;

                token       = json.GetValue("time_24");
                this.time24 = token != null?token.ToObject <String>() : null;

                token       = json.GetValue("time_12");
                this.time12 = token != null?token.ToObject <String>() : null;

                token     = json.GetValue("week");
                this.week = token != null?token.ToObject <String>() : null;

                token      = json.GetValue("month");
                this.month = token != null?token.ToObject <String>() : null;

                token     = json.GetValue("year");
                this.year = token != null?token.ToObject <String>() : null;

                token         = json.GetValue("year_abbr");
                this.yearAbbr = token != null?token.ToObject <String>() : null;

                token      = json.GetValue("is_dst");
                this.isDst = token != null?token.ToObject <Boolean>() : false;

                token           = json.GetValue("dst_savings");
                this.dstSavings = token != null?token.ToObject <Double>() : 0.0;

                token = json.GetValue("geo");
                JObject geoJson = token != null?token.ToObject <JObject>() : null;

                this.timezoneGeo = new TimezoneGeo(geoJson);
            }
            this.status = int.Parse((String)json.GetValue("status"));
        }
コード例 #2
0
        public Timezone(JObject json)
        {
            JToken token = json.GetValue("timezone");

            this.timezone = token != null?token.ToObject <String>() : null;

            token = json.GetValue("timezone_offset");
            this.timezoneOffset = token != null?token.ToObject <Double>() : 0.0;

            token = json.GetValue("timezone_offset_with_dst");
            this.timezoneOffsetWithDST = token != null?token.ToObject <Double>() : 0.0;

            token     = json.GetValue("date");
            this.date = token != null?token.ToObject <String>() : null;

            token         = json.GetValue("date_time");
            this.dateTime = token != null?token.ToObject <String>() : null;

            token            = json.GetValue("date_time_txt");
            this.dateTimeTxt = token != null?token.ToObject <String>() : null;

            token            = json.GetValue("date_time_wti");
            this.dateTimeWti = token != null?token.ToObject <String>() : null;

            token            = json.GetValue("date_time_ymd");
            this.dateTimeYmd = token != null?token.ToObject <String>() : null;

            token             = json.GetValue("date_time_unix");
            this.dateTimeUnix = token != null?token.ToObject <Double>() : 0.0;

            token       = json.GetValue("time_24");
            this.time24 = token != null?token.ToObject <String>() : null;

            token       = json.GetValue("time_12");
            this.time12 = token != null?token.ToObject <String>() : null;

            token     = json.GetValue("week");
            this.week = token != null?token.ToObject <int>() : 0;

            token      = json.GetValue("month");
            this.month = token != null?token.ToObject <int>() : 0;

            token     = json.GetValue("year");
            this.year = token != null?token.ToObject <int>() : 0;

            token         = json.GetValue("year_abbr");
            this.yearAbbr = token != null?token.ToObject <String>() : null;

            token    = json.GetValue("is_dst");
            this.dst = token != null?token.ToObject <Boolean>() : false;

            token           = json.GetValue("dst_savings");
            this.dstSavings = token != null?token.ToObject <Double>() : 0.0;

            token = json.GetValue("geo");
            JObject geoJson = token != null?token.ToObject <JObject>() : null;

            if (geoJson == null)
            {
                this.timezoneGeo = new TimezoneGeo();
            }
            else
            {
                this.timezoneGeo = new TimezoneGeo(geoJson);
            }
        }