コード例 #1
0
        internal void ResolveAmpm(Dictionary <string, object> resolutionDic,
                                  string keyName)
        {
            if (resolutionDic.ContainsKey(keyName))
            {
                var resolution = (Dictionary <string, string>)resolutionDic[keyName];
                if (!resolutionDic.ContainsKey("timex"))
                {
                    return;
                }
                var timex = (string)resolutionDic["timex"];
                resolutionDic.Remove(keyName);

                resolutionDic.Add(keyName + "Am", resolution);

                var resolutionPm = new Dictionary <string, string>();
                switch ((string)resolutionDic["type"])
                {
                case Constants.SYS_DATETIME_TIME:
                    resolutionPm[TimeTypeConstants.VALUE] = FormatUtil.ToPm(resolution[TimeTypeConstants.VALUE]);
                    resolutionPm["timex"] = FormatUtil.ToPm(timex);
                    break;

                case Constants.SYS_DATETIME_DATETIME:
                    var splited = resolution[TimeTypeConstants.VALUE].Split(' ');
                    resolutionPm[TimeTypeConstants.VALUE] = splited[0] + " " + FormatUtil.ToPm(splited[1]);
                    resolutionPm["timex"] = FormatUtil.AllStringToPm(timex);
                    break;

                case Constants.SYS_DATETIME_TIMEPERIOD:
                    if (resolution.ContainsKey(TimeTypeConstants.START))
                    {
                        resolutionPm[TimeTypeConstants.START] = FormatUtil.ToPm(resolution[TimeTypeConstants.START]);
                    }
                    if (resolution.ContainsKey(TimeTypeConstants.END))
                    {
                        resolutionPm[TimeTypeConstants.END] = FormatUtil.ToPm(resolution[TimeTypeConstants.END]);
                    }
                    resolutionPm["timex"] = FormatUtil.AllStringToPm(timex);
                    break;

                case Constants.SYS_DATETIME_DATETIMEPERIOD:
                    splited = resolution[TimeTypeConstants.START].Split(' ');
                    if (resolution.ContainsKey(TimeTypeConstants.START))
                    {
                        resolutionPm[TimeTypeConstants.START] = splited[0] + " " + FormatUtil.ToPm(splited[1]);
                    }
                    splited = resolution[TimeTypeConstants.END].Split(' ');
                    if (resolution.ContainsKey(TimeTypeConstants.END))
                    {
                        resolutionPm[TimeTypeConstants.END] = splited[0] + " " + FormatUtil.ToPm(splited[1]);
                    }
                    resolutionPm["timex"] = FormatUtil.AllStringToPm(timex);
                    break;
                }

                resolutionDic.Add(keyName + "Pm", resolutionPm);
            }
        }
コード例 #2
0
        internal void ResolveAmpm(Dictionary <string, object> resolutionDic, string keyName)
        {
            if (resolutionDic.ContainsKey(keyName))
            {
                var resolution   = (Dictionary <string, string>)resolutionDic[keyName];
                var resolutionPm = new Dictionary <string, string>();

                if (!resolutionDic.ContainsKey(DateTimeResolutionKey.Timex))
                {
                    return;
                }

                var timex = (string)resolutionDic[DateTimeResolutionKey.Timex];

                resolutionDic.Remove(keyName);
                resolutionDic.Add(keyName + "Am", resolution);

                switch ((string)resolutionDic[ResolutionKey.Type])
                {
                case Constants.SYS_DATETIME_TIME:
                    resolutionPm[ResolutionKey.Value]         = FormatUtil.ToPm(resolution[ResolutionKey.Value]);
                    resolutionPm[DateTimeResolutionKey.Timex] = FormatUtil.ToPm(timex);
                    break;

                case Constants.SYS_DATETIME_DATETIME:
                    var splited = resolution[ResolutionKey.Value].Split(' ');
                    resolutionPm[ResolutionKey.Value]         = splited[0] + " " + FormatUtil.ToPm(splited[1]);
                    resolutionPm[DateTimeResolutionKey.Timex] = FormatUtil.AllStringToPm(timex);
                    break;

                case Constants.SYS_DATETIME_TIMEPERIOD:
                    if (resolution.ContainsKey(DateTimeResolutionKey.START))
                    {
                        resolutionPm[DateTimeResolutionKey.START] = FormatUtil.ToPm(resolution[DateTimeResolutionKey.START]);
                    }

                    if (resolution.ContainsKey(DateTimeResolutionKey.END))
                    {
                        resolutionPm[DateTimeResolutionKey.END] = FormatUtil.ToPm(resolution[DateTimeResolutionKey.END]);
                    }

                    resolutionPm[DateTimeResolutionKey.Timex] = FormatUtil.AllStringToPm(timex);
                    break;

                case Constants.SYS_DATETIME_DATETIMEPERIOD:
                    if (resolution.ContainsKey(DateTimeResolutionKey.START))
                    {
                        var start = Convert.ToDateTime(resolution[DateTimeResolutionKey.START]);
                        start = start.Hour == 12 ? start.AddHours(-12) : start.AddHours(12);

                        resolutionPm[DateTimeResolutionKey.START] = FormatUtil.FormatDateTime(start);
                    }

                    if (resolution.ContainsKey(DateTimeResolutionKey.END))
                    {
                        var end = Convert.ToDateTime(resolution[DateTimeResolutionKey.END]);
                        end = end.Hour == 12 ? end.AddHours(-12) : end.AddHours(12);

                        resolutionPm[DateTimeResolutionKey.END] = FormatUtil.FormatDateTime(end);
                    }

                    resolutionPm[DateTimeResolutionKey.Timex] = FormatUtil.AllStringToPm(timex);
                    break;
                }

                resolutionDic.Add(keyName + "Pm", resolutionPm);
            }
        }