Index: generated/natools-static_maps-s_expressions-templates-dates-cmds.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates-cmds.adb +++ generated/natools-static_maps-s_expressions-templates-dates-cmds.adb @@ -4,19 +4,19 @@ P : constant array (0 .. 5) of Natural := (1, 2, 5, 11, 12, 15); T1 : constant array (0 .. 5) of Unsigned_8 := - (5, 22, 23, 31, 6, 10); + (3, 35, 48, 42, 15, 1); T2 : constant array (0 .. 5) of Unsigned_8 := - (42, 40, 11, 44, 54, 41); + (30, 30, 25, 29, 48, 10); - G : constant array (0 .. 57) of Unsigned_8 := - (0, 0, 0, 0, 9, 0, 22, 3, 0, 0, 1, 11, 4, 0, 0, 0, 17, 0, 5, 0, 13, 0, - 0, 0, 0, 0, 0, 0, 0, 16, 0, 2, 0, 15, 0, 0, 5, 18, 0, 0, 0, 0, 6, 10, - 10, 20, 23, 0, 3, 3, 27, 16, 0, 20, 21, 9, 0, 22); + G : constant array (0 .. 60) of Unsigned_8 := + (0, 0, 0, 0, 0, 22, 0, 0, 12, 11, 0, 0, 0, 0, 0, 0, 13, 5, 0, 26, 17, + 0, 0, 6, 9, 0, 0, 0, 0, 10, 0, 24, 0, 0, 0, 0, 7, 6, 28, 16, 23, 0, 0, + 4, 28, 7, 21, 0, 8, 1, 9, 2, 0, 1, 5, 29, 0, 0, 3, 19, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; @@ -23,12 +23,12 @@ J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); - F1 := (F1 + Natural (T1 (K)) * J) mod 58; - F2 := (F2 + Natural (T2 (K)) * J) mod 58; + F1 := (F1 + Natural (T1 (K)) * J) mod 61; + F2 := (F2 + Natural (T2 (K)) * J) mod 61; end loop; - return (Natural (G (F1)) + Natural (G (F2))) mod 28; + return (Natural (G (F1)) + Natural (G (F2))) mod 30; end Hash; end Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds; Index: generated/natools-static_maps-s_expressions-templates-dates-t.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates-t.adb +++ generated/natools-static_maps-s_expressions-templates-dates-t.adb @@ -1,17 +1,26 @@ --- Generated at 2014-10-03 21:03:09 +0000 by Natools.Static_Hash_Maps +-- Generated at 2015-06-24 18:19:13 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-dates-maps.sx with Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds; +with Natools.Static_Maps.S_Expressions.Templates.Dates.Zones; function Natools.Static_Maps.S_Expressions.Templates.Dates.T return Boolean is begin for I in Map_1_Keys'Range loop if Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds.Hash (Map_1_Keys (I).all) /= I then + return False; + end if; + end loop; + + for I in Map_2_Keys'Range loop + if Natools.Static_Maps.S_Expressions.Templates.Dates.Zones.Hash + (Map_2_Keys (I).all) /= I + then return False; end if; end loop; return True; end Natools.Static_Maps.S_Expressions.Templates.Dates.T; Index: generated/natools-static_maps-s_expressions-templates-dates-t.ads ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates-t.ads +++ generated/natools-static_maps-s_expressions-templates-dates-t.ads @@ -1,6 +1,6 @@ --- Generated at 2014-10-03 21:03:09 +0000 by Natools.Static_Hash_Maps +-- Generated at 2015-06-24 18:19:13 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-dates-maps.sx function Natools.Static_Maps.S_Expressions.Templates.Dates.T return Boolean; pragma Pure (Natools.Static_Maps.S_Expressions.Templates.Dates.T); ADDED generated/natools-static_maps-s_expressions-templates-dates-zones.adb Index: generated/natools-static_maps-s_expressions-templates-dates-zones.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates-zones.adb +++ generated/natools-static_maps-s_expressions-templates-dates-zones.adb @@ -0,0 +1,49 @@ +with Interfaces; use Interfaces; + +package body Natools.Static_Maps.S_Expressions.Templates.Dates.Zones is + + P : constant array (0 .. 3) of Natural := + (1, 2, 3, 4); + + T1 : constant array (0 .. 3) of Unsigned_16 := + (174, 296, 87, 202); + + T2 : constant array (0 .. 3) of Unsigned_16 := + (5, 119, 245, 172); + + G : constant array (0 .. 332) of Unsigned_8 := + (0, 85, 0, 0, 71, 0, 0, 104, 0, 149, 0, 0, 145, 0, 100, 51, 134, 3, 0, + 0, 136, 22, 0, 43, 0, 133, 0, 0, 0, 0, 0, 0, 18, 106, 87, 110, 0, 48, + 0, 0, 63, 0, 52, 0, 0, 83, 42, 0, 0, 66, 0, 0, 0, 0, 0, 72, 0, 83, 0, + 36, 33, 157, 0, 41, 0, 156, 0, 0, 116, 11, 4, 0, 129, 125, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4, 61, 0, 0, 80, 7, 35, 0, 0, 0, 0, 0, 30, 5, + 140, 81, 111, 74, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 45, 16, 2, + 108, 149, 109, 0, 0, 1, 0, 0, 158, 0, 164, 0, 139, 40, 0, 0, 0, 0, 0, + 116, 0, 0, 64, 129, 39, 159, 0, 0, 75, 5, 0, 0, 0, 55, 0, 106, 24, + 154, 0, 67, 86, 0, 9, 0, 65, 0, 50, 0, 0, 94, 47, 0, 0, 86, 6, 0, 61, + 0, 0, 75, 0, 38, 73, 30, 16, 120, 0, 0, 0, 16, 0, 0, 80, 0, 140, 44, + 146, 0, 0, 0, 0, 0, 27, 0, 0, 0, 90, 83, 32, 28, 0, 0, 104, 0, 83, 0, + 0, 0, 109, 16, 0, 112, 0, 0, 0, 66, 37, 0, 25, 70, 59, 70, 0, 24, 0, + 131, 0, 0, 0, 0, 45, 0, 0, 4, 0, 41, 97, 0, 0, 0, 17, 21, 0, 0, 0, 69, + 160, 5, 0, 0, 46, 64, 0, 68, 0, 5, 142, 8, 0, 0, 7, 79, 103, 77, 0, 0, + 138, 0, 163, 0, 43, 74, 0, 0, 134, 13, 54, 114, 51, 44, 0, 131, 32, + 13, 15, 148, 35, 94, 0, 31, 0, 0, 0, 144, 0, 84, 39, 0, 0, 125, 58, 0, + 0, 4, 12, 0, 0, 60, 11, 64, 0, 0, 0, 34, 14, 158, 145, 0, 23, 0, 143, + 163, 0, 96); + + function Hash (S : String) return Natural is + F : constant Natural := S'First - 1; + L : constant Natural := S'Length; + F1, F2 : Natural := 0; + J : Natural; + begin + for K in P'Range loop + exit when L < P (K); + J := Character'Pos (S (P (K) + F)); + F1 := (F1 + Natural (T1 (K)) * J) mod 333; + F2 := (F2 + Natural (T2 (K)) * J) mod 333; + end loop; + return (Natural (G (F1)) + Natural (G (F2))) mod 166; + end Hash; + +end Natools.Static_Maps.S_Expressions.Templates.Dates.Zones; ADDED generated/natools-static_maps-s_expressions-templates-dates-zones.ads Index: generated/natools-static_maps-s_expressions-templates-dates-zones.ads ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates-zones.ads +++ generated/natools-static_maps-s_expressions-templates-dates-zones.ads @@ -0,0 +1,4 @@ +package Natools.Static_Maps.S_Expressions.Templates.Dates.Zones is + pragma Pure; + function Hash (S : String) return Natural; +end Natools.Static_Maps.S_Expressions.Templates.Dates.Zones; Index: generated/natools-static_maps-s_expressions-templates-dates.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates.adb +++ generated/natools-static_maps-s_expressions-templates-dates.adb @@ -1,9 +1,10 @@ --- Generated at 2014-10-03 21:03:09 +0000 by Natools.Static_Hash_Maps +-- Generated at 2015-06-24 18:19:13 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-dates-maps.sx with Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds; +with Natools.Static_Maps.S_Expressions.Templates.Dates.Zones; package body Natools.Static_Maps.S_Expressions.Templates.Dates is function Main (Key : String) return Main_Command is N : constant Natural @@ -14,6 +15,18 @@ else return Error; end if; end Main; + + function To_Time_Offset (Key : String) return Integer is + N : constant Natural + := Natools.Static_Maps.S_Expressions.Templates.Dates.Zones.Hash (Key); + begin + if Map_2_Keys (N).all = Key then + return Map_2_Elements (N); + else + raise Constraint_Error with "Key """ & Key & """ not in map"; + end if; + end To_Time_Offset; + end Natools.Static_Maps.S_Expressions.Templates.Dates; Index: generated/natools-static_maps-s_expressions-templates-dates.ads ================================================================== --- generated/natools-static_maps-s_expressions-templates-dates.ads +++ generated/natools-static_maps-s_expressions-templates-dates.ads @@ -1,6 +1,6 @@ --- Generated at 2014-10-03 21:03:09 +0000 by Natools.Static_Hash_Maps +-- Generated at 2015-06-24 18:19:13 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-dates-maps.sx package Natools.Static_Maps.S_Expressions.Templates.Dates is pragma Pure; @@ -10,13 +10,14 @@ Padded_Month, Padded_Day, Padded_Hour, Padded_Minute, Padded_Second, Day_Of_Week, Big_Endian_Date, Little_Endian_Date, Big_Endian_Time, Little_Endian_Time, - RFC_3339); + RFC_3339, With_Offset); function Main (Key : String) return Main_Command; + function To_Time_Offset (Key : String) return Integer; private Map_1_Key_0 : aliased constant String := "YYYYMMDD"; Map_1_Key_1 : aliased constant String := "big-endian-date"; @@ -43,12 +44,14 @@ Map_1_Key_22 : aliased constant String := "padded-month"; Map_1_Key_23 : aliased constant String := "0second"; Map_1_Key_24 : aliased constant String := "padded-second"; Map_1_Key_25 : aliased constant String := "rfc-3339"; Map_1_Key_26 : aliased constant String := "second"; - Map_1_Key_27 : aliased constant String := "year"; - Map_1_Keys : constant array (0 .. 27) of access constant String + Map_1_Key_27 : aliased constant String := "with-offset"; + Map_1_Key_28 : aliased constant String := "in-zone"; + Map_1_Key_29 : aliased constant String := "year"; + Map_1_Keys : constant array (0 .. 29) of access constant String := (Map_1_Key_0'Access, Map_1_Key_1'Access, Map_1_Key_2'Access, Map_1_Key_3'Access, Map_1_Key_4'Access, @@ -72,12 +75,14 @@ Map_1_Key_22'Access, Map_1_Key_23'Access, Map_1_Key_24'Access, Map_1_Key_25'Access, Map_1_Key_26'Access, - Map_1_Key_27'Access); - Map_1_Elements : constant array (0 .. 27) of Main_Command + Map_1_Key_27'Access, + Map_1_Key_28'Access, + Map_1_Key_29'Access); + Map_1_Elements : constant array (0 .. 29) of Main_Command := (Big_Endian_Date, Big_Endian_Date, Big_Endian_Time, Big_Endian_Time, Big_Endian_Time, @@ -101,8 +106,511 @@ Padded_Month, Padded_Second, Padded_Second, RFC_3339, Second, + With_Offset, + With_Offset, Year); + + Map_2_Key_0 : aliased constant String := "ACDT"; + Map_2_Key_1 : aliased constant String := "ACST"; + Map_2_Key_2 : aliased constant String := "ADT"; + Map_2_Key_3 : aliased constant String := "AEDT"; + Map_2_Key_4 : aliased constant String := "AEST"; + Map_2_Key_5 : aliased constant String := "AFT"; + Map_2_Key_6 : aliased constant String := "AKDT"; + Map_2_Key_7 : aliased constant String := "AKST"; + Map_2_Key_8 : aliased constant String := "ART"; + Map_2_Key_9 : aliased constant String := "AWDT"; + Map_2_Key_10 : aliased constant String := "AWST"; + Map_2_Key_11 : aliased constant String := "AZOST"; + Map_2_Key_12 : aliased constant String := "AZT"; + Map_2_Key_13 : aliased constant String := "BDT"; + Map_2_Key_14 : aliased constant String := "BIOT"; + Map_2_Key_15 : aliased constant String := "BIT"; + Map_2_Key_16 : aliased constant String := "BOT"; + Map_2_Key_17 : aliased constant String := "BRST"; + Map_2_Key_18 : aliased constant String := "BRT"; + Map_2_Key_19 : aliased constant String := "BTT"; + Map_2_Key_20 : aliased constant String := "CAT"; + Map_2_Key_21 : aliased constant String := "CCT"; + Map_2_Key_22 : aliased constant String := "CEDT"; + Map_2_Key_23 : aliased constant String := "CEST"; + Map_2_Key_24 : aliased constant String := "CET"; + Map_2_Key_25 : aliased constant String := "CHADT"; + Map_2_Key_26 : aliased constant String := "CHAST"; + Map_2_Key_27 : aliased constant String := "CHOT"; + Map_2_Key_28 : aliased constant String := "ChST"; + Map_2_Key_29 : aliased constant String := "CHUT"; + Map_2_Key_30 : aliased constant String := "CIST"; + Map_2_Key_31 : aliased constant String := "CIT"; + Map_2_Key_32 : aliased constant String := "CKT"; + Map_2_Key_33 : aliased constant String := "CLST"; + Map_2_Key_34 : aliased constant String := "CLT"; + Map_2_Key_35 : aliased constant String := "COST"; + Map_2_Key_36 : aliased constant String := "COT"; + Map_2_Key_37 : aliased constant String := "CT"; + Map_2_Key_38 : aliased constant String := "CVT"; + Map_2_Key_39 : aliased constant String := "CWST"; + Map_2_Key_40 : aliased constant String := "CXT"; + Map_2_Key_41 : aliased constant String := "DAVT"; + Map_2_Key_42 : aliased constant String := "DDUT"; + Map_2_Key_43 : aliased constant String := "DFT"; + Map_2_Key_44 : aliased constant String := "EASST"; + Map_2_Key_45 : aliased constant String := "EAST"; + Map_2_Key_46 : aliased constant String := "EAT"; + Map_2_Key_47 : aliased constant String := "EDT"; + Map_2_Key_48 : aliased constant String := "EEDT"; + Map_2_Key_49 : aliased constant String := "EEST"; + Map_2_Key_50 : aliased constant String := "EET"; + Map_2_Key_51 : aliased constant String := "EGST"; + Map_2_Key_52 : aliased constant String := "EGT"; + Map_2_Key_53 : aliased constant String := "EIT"; + Map_2_Key_54 : aliased constant String := "FET"; + Map_2_Key_55 : aliased constant String := "FJT"; + Map_2_Key_56 : aliased constant String := "FKST"; + Map_2_Key_57 : aliased constant String := "FKT"; + Map_2_Key_58 : aliased constant String := "FNT"; + Map_2_Key_59 : aliased constant String := "GALT"; + Map_2_Key_60 : aliased constant String := "GAMT"; + Map_2_Key_61 : aliased constant String := "GET"; + Map_2_Key_62 : aliased constant String := "GFT"; + Map_2_Key_63 : aliased constant String := "GILT"; + Map_2_Key_64 : aliased constant String := "GIT"; + Map_2_Key_65 : aliased constant String := "GMT"; + Map_2_Key_66 : aliased constant String := "GYT"; + Map_2_Key_67 : aliased constant String := "HADT"; + Map_2_Key_68 : aliased constant String := "HAEC"; + Map_2_Key_69 : aliased constant String := "HAST"; + Map_2_Key_70 : aliased constant String := "HKT"; + Map_2_Key_71 : aliased constant String := "HMT"; + Map_2_Key_72 : aliased constant String := "HOVT"; + Map_2_Key_73 : aliased constant String := "HST"; + Map_2_Key_74 : aliased constant String := "ICT"; + Map_2_Key_75 : aliased constant String := "IDT"; + Map_2_Key_76 : aliased constant String := "IOT"; + Map_2_Key_77 : aliased constant String := "IRDT"; + Map_2_Key_78 : aliased constant String := "IRKT"; + Map_2_Key_79 : aliased constant String := "IRST"; + Map_2_Key_80 : aliased constant String := "JST"; + Map_2_Key_81 : aliased constant String := "KGT"; + Map_2_Key_82 : aliased constant String := "KOST"; + Map_2_Key_83 : aliased constant String := "KRAT"; + Map_2_Key_84 : aliased constant String := "KST"; + Map_2_Key_85 : aliased constant String := "LINT"; + Map_2_Key_86 : aliased constant String := "MAGT"; + Map_2_Key_87 : aliased constant String := "MART"; + Map_2_Key_88 : aliased constant String := "MAWT"; + Map_2_Key_89 : aliased constant String := "MDT"; + Map_2_Key_90 : aliased constant String := "MET"; + Map_2_Key_91 : aliased constant String := "MEST"; + Map_2_Key_92 : aliased constant String := "MHT"; + Map_2_Key_93 : aliased constant String := "MIST"; + Map_2_Key_94 : aliased constant String := "MIT"; + Map_2_Key_95 : aliased constant String := "MMT"; + Map_2_Key_96 : aliased constant String := "MSK"; + Map_2_Key_97 : aliased constant String := "MUT"; + Map_2_Key_98 : aliased constant String := "MVT"; + Map_2_Key_99 : aliased constant String := "MYT"; + Map_2_Key_100 : aliased constant String := "NCT"; + Map_2_Key_101 : aliased constant String := "NDT"; + Map_2_Key_102 : aliased constant String := "NFT"; + Map_2_Key_103 : aliased constant String := "NPT"; + Map_2_Key_104 : aliased constant String := "NST"; + Map_2_Key_105 : aliased constant String := "NT"; + Map_2_Key_106 : aliased constant String := "NUT"; + Map_2_Key_107 : aliased constant String := "NZDT"; + Map_2_Key_108 : aliased constant String := "NZST"; + Map_2_Key_109 : aliased constant String := "OMST"; + Map_2_Key_110 : aliased constant String := "ORAT"; + Map_2_Key_111 : aliased constant String := "PDT"; + Map_2_Key_112 : aliased constant String := "PET"; + Map_2_Key_113 : aliased constant String := "PETT"; + Map_2_Key_114 : aliased constant String := "PGT"; + Map_2_Key_115 : aliased constant String := "PHOT"; + Map_2_Key_116 : aliased constant String := "PKT"; + Map_2_Key_117 : aliased constant String := "PMDT"; + Map_2_Key_118 : aliased constant String := "PMST"; + Map_2_Key_119 : aliased constant String := "PONT"; + Map_2_Key_120 : aliased constant String := "PYST"; + Map_2_Key_121 : aliased constant String := "PYT"; + Map_2_Key_122 : aliased constant String := "RET"; + Map_2_Key_123 : aliased constant String := "ROTT"; + Map_2_Key_124 : aliased constant String := "SAKT"; + Map_2_Key_125 : aliased constant String := "SAMT"; + Map_2_Key_126 : aliased constant String := "SAST"; + Map_2_Key_127 : aliased constant String := "SBT"; + Map_2_Key_128 : aliased constant String := "SCT"; + Map_2_Key_129 : aliased constant String := "SGT"; + Map_2_Key_130 : aliased constant String := "SLST"; + Map_2_Key_131 : aliased constant String := "SRET"; + Map_2_Key_132 : aliased constant String := "SRT"; + Map_2_Key_133 : aliased constant String := "SYOT"; + Map_2_Key_134 : aliased constant String := "TAHT"; + Map_2_Key_135 : aliased constant String := "THA"; + Map_2_Key_136 : aliased constant String := "TFT"; + Map_2_Key_137 : aliased constant String := "TJT"; + Map_2_Key_138 : aliased constant String := "TKT"; + Map_2_Key_139 : aliased constant String := "TLT"; + Map_2_Key_140 : aliased constant String := "TMT"; + Map_2_Key_141 : aliased constant String := "TOT"; + Map_2_Key_142 : aliased constant String := "TVT"; + Map_2_Key_143 : aliased constant String := "UCT"; + Map_2_Key_144 : aliased constant String := "ULAT"; + Map_2_Key_145 : aliased constant String := "USZ1"; + Map_2_Key_146 : aliased constant String := "UTC"; + Map_2_Key_147 : aliased constant String := "UYST"; + Map_2_Key_148 : aliased constant String := "UYT"; + Map_2_Key_149 : aliased constant String := "UZT"; + Map_2_Key_150 : aliased constant String := "VET"; + Map_2_Key_151 : aliased constant String := "VLAT"; + Map_2_Key_152 : aliased constant String := "VOLT"; + Map_2_Key_153 : aliased constant String := "VOST"; + Map_2_Key_154 : aliased constant String := "VUT"; + Map_2_Key_155 : aliased constant String := "WAKT"; + Map_2_Key_156 : aliased constant String := "WAST"; + Map_2_Key_157 : aliased constant String := "WAT"; + Map_2_Key_158 : aliased constant String := "WEDT"; + Map_2_Key_159 : aliased constant String := "WEST"; + Map_2_Key_160 : aliased constant String := "WET"; + Map_2_Key_161 : aliased constant String := "WIT"; + Map_2_Key_162 : aliased constant String := "WST"; + Map_2_Key_163 : aliased constant String := "YAKT"; + Map_2_Key_164 : aliased constant String := "YEKT"; + Map_2_Key_165 : aliased constant String := "Z"; + Map_2_Keys : constant array (0 .. 165) of access constant String + := (Map_2_Key_0'Access, + Map_2_Key_1'Access, + Map_2_Key_2'Access, + Map_2_Key_3'Access, + Map_2_Key_4'Access, + Map_2_Key_5'Access, + Map_2_Key_6'Access, + Map_2_Key_7'Access, + Map_2_Key_8'Access, + Map_2_Key_9'Access, + Map_2_Key_10'Access, + Map_2_Key_11'Access, + Map_2_Key_12'Access, + Map_2_Key_13'Access, + Map_2_Key_14'Access, + Map_2_Key_15'Access, + Map_2_Key_16'Access, + Map_2_Key_17'Access, + Map_2_Key_18'Access, + Map_2_Key_19'Access, + Map_2_Key_20'Access, + Map_2_Key_21'Access, + Map_2_Key_22'Access, + Map_2_Key_23'Access, + Map_2_Key_24'Access, + Map_2_Key_25'Access, + Map_2_Key_26'Access, + Map_2_Key_27'Access, + Map_2_Key_28'Access, + Map_2_Key_29'Access, + Map_2_Key_30'Access, + Map_2_Key_31'Access, + Map_2_Key_32'Access, + Map_2_Key_33'Access, + Map_2_Key_34'Access, + Map_2_Key_35'Access, + Map_2_Key_36'Access, + Map_2_Key_37'Access, + Map_2_Key_38'Access, + Map_2_Key_39'Access, + Map_2_Key_40'Access, + Map_2_Key_41'Access, + Map_2_Key_42'Access, + Map_2_Key_43'Access, + Map_2_Key_44'Access, + Map_2_Key_45'Access, + Map_2_Key_46'Access, + Map_2_Key_47'Access, + Map_2_Key_48'Access, + Map_2_Key_49'Access, + Map_2_Key_50'Access, + Map_2_Key_51'Access, + Map_2_Key_52'Access, + Map_2_Key_53'Access, + Map_2_Key_54'Access, + Map_2_Key_55'Access, + Map_2_Key_56'Access, + Map_2_Key_57'Access, + Map_2_Key_58'Access, + Map_2_Key_59'Access, + Map_2_Key_60'Access, + Map_2_Key_61'Access, + Map_2_Key_62'Access, + Map_2_Key_63'Access, + Map_2_Key_64'Access, + Map_2_Key_65'Access, + Map_2_Key_66'Access, + Map_2_Key_67'Access, + Map_2_Key_68'Access, + Map_2_Key_69'Access, + Map_2_Key_70'Access, + Map_2_Key_71'Access, + Map_2_Key_72'Access, + Map_2_Key_73'Access, + Map_2_Key_74'Access, + Map_2_Key_75'Access, + Map_2_Key_76'Access, + Map_2_Key_77'Access, + Map_2_Key_78'Access, + Map_2_Key_79'Access, + Map_2_Key_80'Access, + Map_2_Key_81'Access, + Map_2_Key_82'Access, + Map_2_Key_83'Access, + Map_2_Key_84'Access, + Map_2_Key_85'Access, + Map_2_Key_86'Access, + Map_2_Key_87'Access, + Map_2_Key_88'Access, + Map_2_Key_89'Access, + Map_2_Key_90'Access, + Map_2_Key_91'Access, + Map_2_Key_92'Access, + Map_2_Key_93'Access, + Map_2_Key_94'Access, + Map_2_Key_95'Access, + Map_2_Key_96'Access, + Map_2_Key_97'Access, + Map_2_Key_98'Access, + Map_2_Key_99'Access, + Map_2_Key_100'Access, + Map_2_Key_101'Access, + Map_2_Key_102'Access, + Map_2_Key_103'Access, + Map_2_Key_104'Access, + Map_2_Key_105'Access, + Map_2_Key_106'Access, + Map_2_Key_107'Access, + Map_2_Key_108'Access, + Map_2_Key_109'Access, + Map_2_Key_110'Access, + Map_2_Key_111'Access, + Map_2_Key_112'Access, + Map_2_Key_113'Access, + Map_2_Key_114'Access, + Map_2_Key_115'Access, + Map_2_Key_116'Access, + Map_2_Key_117'Access, + Map_2_Key_118'Access, + Map_2_Key_119'Access, + Map_2_Key_120'Access, + Map_2_Key_121'Access, + Map_2_Key_122'Access, + Map_2_Key_123'Access, + Map_2_Key_124'Access, + Map_2_Key_125'Access, + Map_2_Key_126'Access, + Map_2_Key_127'Access, + Map_2_Key_128'Access, + Map_2_Key_129'Access, + Map_2_Key_130'Access, + Map_2_Key_131'Access, + Map_2_Key_132'Access, + Map_2_Key_133'Access, + Map_2_Key_134'Access, + Map_2_Key_135'Access, + Map_2_Key_136'Access, + Map_2_Key_137'Access, + Map_2_Key_138'Access, + Map_2_Key_139'Access, + Map_2_Key_140'Access, + Map_2_Key_141'Access, + Map_2_Key_142'Access, + Map_2_Key_143'Access, + Map_2_Key_144'Access, + Map_2_Key_145'Access, + Map_2_Key_146'Access, + Map_2_Key_147'Access, + Map_2_Key_148'Access, + Map_2_Key_149'Access, + Map_2_Key_150'Access, + Map_2_Key_151'Access, + Map_2_Key_152'Access, + Map_2_Key_153'Access, + Map_2_Key_154'Access, + Map_2_Key_155'Access, + Map_2_Key_156'Access, + Map_2_Key_157'Access, + Map_2_Key_158'Access, + Map_2_Key_159'Access, + Map_2_Key_160'Access, + Map_2_Key_161'Access, + Map_2_Key_162'Access, + Map_2_Key_163'Access, + Map_2_Key_164'Access, + Map_2_Key_165'Access); + Map_2_Elements : constant array (0 .. 165) of Integer + := (+10 * 60 + 30, + +09 * 60 + 30, + -03 * 60, + +11 * 60, + +10 * 60, + +04 * 60 + 30, + -08 * 60, + -09 * 60, + -03 * 60, + +09 * 60, + +08 * 60, + -01 * 60, + +04 * 60, + +08 * 60, + +06 * 60, + -12 * 60, + -04 * 60, + -02 * 60, + -03 * 60, + +06 * 60, + +02 * 60, + +06 * 60 + 30, + +02 * 60, + +02 * 60, + +01 * 60, + +13 * 60 + 45, + +12 * 60 + 45, + +08 * 60, + +10 * 60, + +10 * 60, + -08 * 60, + +08 * 60, + -10 * 60, + -03 * 60, + -04 * 60, + -04 * 60, + -05 * 60, + +08 * 60, + -01 * 60, + +08 * 60 + 45, + +07 * 60, + +07 * 60, + +10 * 60, + +01 * 60, + -05 * 60, + -06 * 60, + +03 * 60, + -04 * 60, + +03 * 60, + +03 * 60, + +02 * 60, + +00 * 60, + -01 * 60, + +09 * 60, + +03 * 60, + +12 * 60, + -03 * 60, + -04 * 60, + -02 * 60, + -06 * 60, + -09 * 60, + +04 * 60, + -03 * 60, + +12 * 60, + -09 * 60, + 0, + -04 * 60, + -09 * 60, + +02 * 60, + -10 * 60, + +08 * 60, + +05 * 60, + +07 * 60, + -10 * 60, + +07 * 60, + +03 * 60, + +03 * 60, + +04 * 60 + 30, + +08 * 60, + +03 * 60 + 30, + +09 * 60, + +06 * 60, + +11 * 60, + +07 * 60, + +09 * 60, + +14 * 60, + +12 * 60, + -09 * 60 + 30, + +05 * 60, + -06 * 60, + +01 * 60, + +02 * 60, + +12 * 60, + +11 * 60, + -09 * 60 + 30, + +06 * 60 + 30, + +03 * 60, + +04 * 60, + +05 * 60, + +08 * 60, + +11 * 60, + -02 * 60 + 30, + +11 * 60 + 30, + +05 * 60 + 45, + -03 * 60 + 30, + -03 * 60 + 30, + -11 * 60, + +13 * 60, + +12 * 60, + +06 * 60, + +05 * 60, + -07 * 60, + -05 * 60, + +12 * 60, + +10 * 60, + +13 * 60, + +05 * 60, + -02 * 60, + -03 * 60, + +11 * 60, + -03 * 60, + -04 * 60, + +04 * 60, + -03 * 60, + +11 * 60, + +04 * 60, + +02 * 60, + +11 * 60, + +04 * 60, + +08 * 60, + +05 * 60 + 30, + +11 * 60, + -03 * 60, + +03 * 60, + -10 * 60, + +07 * 60, + +05 * 60, + +05 * 60, + +13 * 60, + +09 * 60, + +05 * 60, + +13 * 60, + +12 * 60, + 0, + +08 * 60, + +02 * 60, + 0, + -02 * 60, + -03 * 60, + +05 * 60, + -04 * 60 + 30, + +10 * 60, + +04 * 60, + +06 * 60, + +11 * 60, + +12 * 60, + +02 * 60, + +01 * 60, + +01 * 60, + +01 * 60, + 0, + +07 * 60, + +08 * 60, + +09 * 60, + +05 * 60, + 0); end Natools.Static_Maps.S_Expressions.Templates.Dates; Index: src/natools-s_expressions-templates-dates-maps.sx ================================================================== --- src/natools-s_expressions-templates-dates-maps.sx +++ src/natools-s_expressions-templates-dates-maps.sx @@ -8,11 +8,11 @@ Padded_Month, Padded_Day, Padded_Hour, Padded_Minute, Padded_Second, Day_Of_Week, Big_Endian_Date, Little_Endian_Date, Big_Endian_Time, Little_Endian_Time, - RFC_3339);") + RFC_3339, With_Offset);") (Main_Command (hash-package Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds) (function Main) (not-found Error) (nodes @@ -30,6 +30,177 @@ (Padded_Minute 0minute padded-minute) (Padded_Month 0month padded-month) (Padded_Second 0second padded-second) (RFC_3339 rfc-3339) (Second second) - (Year year)))) + (With_Offset with-offset in-zone) + (Year year))) + (Integer + (hash-package Natools.Static_Maps.S_Expressions.Templates.Dates.Zones) + (function To_Time_Offset) + (nodes + ("+10 * 60 + 30" ACDT) + ("+09 * 60 + 30" ACST) + ("-03 * 60" ADT) + ("+11 * 60" AEDT) + ("+10 * 60" AEST) + ("+04 * 60 + 30" AFT) + ("-08 * 60" AKDT) + ("-09 * 60" AKST) + ("-03 * 60" ART) + ("+09 * 60" AWDT) + ("+08 * 60" AWST) + ("-01 * 60" AZOST) + ("+04 * 60" AZT) + ("+08 * 60" BDT) + ("+06 * 60" BIOT) + ("-12 * 60" BIT) + ("-04 * 60" BOT) + ("-02 * 60" BRST) + ("-03 * 60" BRT) + ("+06 * 60" BTT) + ("+02 * 60" CAT) + ("+06 * 60 + 30" CCT) + ("+02 * 60" CEDT) + ("+02 * 60" CEST) + ("+01 * 60" CET) + ("+13 * 60 + 45" CHADT) + ("+12 * 60 + 45" CHAST) + ("+08 * 60" CHOT) + ("+10 * 60" ChST) + ("+10 * 60" CHUT) + ("-08 * 60" CIST) + ("+08 * 60" CIT) + ("-10 * 60" CKT) + ("-03 * 60" CLST) + ("-04 * 60" CLT) + ("-04 * 60" COST) + ("-05 * 60" COT) + ("+08 * 60" CT) + ("-01 * 60" CVT) + ("+08 * 60 + 45" CWST) + ("+07 * 60" CXT) + ("+07 * 60" DAVT) + ("+10 * 60" DDUT) + ("+01 * 60" DFT) + ("-05 * 60" EASST) + ("-06 * 60" EAST) + ("+03 * 60" EAT) + ("-04 * 60" EDT) + ("+03 * 60" EEDT) + ("+03 * 60" EEST) + ("+02 * 60" EET) + ("+00 * 60" EGST) + ("-01 * 60" EGT) + ("+09 * 60" EIT) + ("+03 * 60" FET) + ("+12 * 60" FJT) + ("-03 * 60" FKST) + ("-04 * 60" FKT) + ("-02 * 60" FNT) + ("-06 * 60" GALT) + ("-09 * 60" GAMT) + ("+04 * 60" GET) + ("-03 * 60" GFT) + ("+12 * 60" GILT) + ("-09 * 60" GIT) + ("0" GMT) + ("-04 * 60" GYT) + ("-09 * 60" HADT) + ("+02 * 60" HAEC) + ("-10 * 60" HAST) + ("+08 * 60" HKT) + ("+05 * 60" HMT) + ("+07 * 60" HOVT) + ("-10 * 60" HST) + ("+07 * 60" ICT) + ("+03 * 60" IDT) + ("+03 * 60" IOT) + ("+04 * 60 + 30" IRDT) + ("+08 * 60" IRKT) + ("+03 * 60 + 30" IRST) + ("+09 * 60" JST) + ("+06 * 60" KGT) + ("+11 * 60" KOST) + ("+07 * 60" KRAT) + ("+09 * 60" KST) + ("+14 * 60" LINT) + ("+12 * 60" MAGT) + ("-09 * 60 + 30" MART) + ("+05 * 60" MAWT) + ("-06 * 60" MDT) + ("+01 * 60" MET) + ("+02 * 60" MEST) + ("+12 * 60" MHT) + ("+11 * 60" MIST) + ("-09 * 60 + 30" MIT) + ("+06 * 60 + 30" MMT) + ("+03 * 60" MSK) + ("+04 * 60" MUT) + ("+05 * 60" MVT) + ("+08 * 60" MYT) + ("+11 * 60" NCT) + ("-02 * 60 + 30" NDT) + ("+11 * 60 + 30" NFT) + ("+05 * 60 + 45" NPT) + ("-03 * 60 + 30" NST) + ("-03 * 60 + 30" NT) + ("-11 * 60" NUT) + ("+13 * 60" NZDT) + ("+12 * 60" NZST) + ("+06 * 60" OMST) + ("+05 * 60" ORAT) + ("-07 * 60" PDT) + ("-05 * 60" PET) + ("+12 * 60" PETT) + ("+10 * 60" PGT) + ("+13 * 60" PHOT) + ("+05 * 60" PKT) + ("-02 * 60" PMDT) + ("-03 * 60" PMST) + ("+11 * 60" PONT) + ("-03 * 60" PYST) + ("-04 * 60" PYT) + ("+04 * 60" RET) + ("-03 * 60" ROTT) + ("+11 * 60" SAKT) + ("+04 * 60" SAMT) + ("+02 * 60" SAST) + ("+11 * 60" SBT) + ("+04 * 60" SCT) + ("+08 * 60" SGT) + ("+05 * 60 + 30" SLST) + ("+11 * 60" SRET) + ("-03 * 60" SRT) + ("+03 * 60" SYOT) + ("-10 * 60" TAHT) + ("+07 * 60" THA) + ("+05 * 60" TFT) + ("+05 * 60" TJT) + ("+13 * 60" TKT) + ("+09 * 60" TLT) + ("+05 * 60" TMT) + ("+13 * 60" TOT) + ("+12 * 60" TVT) + ("0" UCT) + ("+08 * 60" ULAT) + ("+02 * 60" USZ1) + ("0" UTC) + ("-02 * 60" UYST) + ("-03 * 60" UYT) + ("+05 * 60" UZT) + ("-04 * 60 + 30" VET) + ("+10 * 60" VLAT) + ("+04 * 60" VOLT) + ("+06 * 60" VOST) + ("+11 * 60" VUT) + ("+12 * 60" WAKT) + ("+02 * 60" WAST) + ("+01 * 60" WAT) + ("+01 * 60" WEDT) + ("+01 * 60" WEST) + ("0" WET) + ("+07 * 60" WIT) + ("+08 * 60" WST) + ("+09 * 60" YAKT) + ("+05 * 60" YEKT) + ("0" Z)))) Index: src/natools-s_expressions-templates-dates.adb ================================================================== --- src/natools-s_expressions-templates-dates.adb +++ src/natools-s_expressions-templates-dates.adb @@ -51,19 +51,110 @@ 2 => Character'Pos ('0') + Octet ((Value / 100) mod 10), 3 => Character'Pos ('0') + Octet ((Value / 10) mod 10), 4 => Character'Pos ('0') + Octet (Value mod 10))) with Pre => Value in 0 .. 9999; + function Parse_Time_Offset + (Image : in String; + Date : in Ada.Calendar.Time) + return Ada.Calendar.Time_Zones.Time_Offset; + procedure Render_Triplet (Output : in out Ada.Streams.Root_Stream_Type'Class; Part_1, Part_2, Part_3 : in Atom; Template : in out Lockable.Descriptor'Class); + + procedure Interpreter is new Interpreter_Loop + (Ada.Streams.Root_Stream_Type'Class, Split_Time, Execute, Append); + ------------------------------ -- Local Helper Subprograms -- ------------------------------ + + function Parse_Time_Offset + (Image : in String; + Date : in Ada.Calendar.Time) + return Ada.Calendar.Time_Zones.Time_Offset + is + function Value (C : Character) + return Ada.Calendar.Time_Zones.Time_Offset; + + function Value (C : Character) + return Ada.Calendar.Time_Zones.Time_Offset is + begin + if C in '0' .. '9' then + return Ada.Calendar.Time_Zones.Time_Offset + (Character'Pos (C) - Character'Pos ('0')); + else + raise Constraint_Error with "Unknown time offset format"; + end if; + end Value; + begin + if Image = "system" then + return Ada.Calendar.Time_Zones.UTC_Time_Offset (Date); + end if; + + Abbreviation : + begin + return Ada.Calendar.Time_Zones.Time_Offset + (Static_Maps.S_Expressions.Templates.Dates.To_Time_Offset (Image)); + exception + when Constraint_Error => null; + end Abbreviation; + + Numeric : + declare + use type Ada.Calendar.Time_Zones.Time_Offset; + First : Integer := Image'First; + Length : Natural := Image'Length; + V : Ada.Calendar.Time_Zones.Time_Offset; + Negative : Boolean := False; + begin + if First in Image'Range and then Image (First) in '-' | '+' then + Negative := Image (First) = '-'; + First := First + 1; + Length := Length - 1; + end if; + + case Length is + when 1 => + V := Value (Image (First)) * 60; + + when 2 => + V := Value (Image (First)) * 600 + + Value (Image (First + 1)) * 60; + + when 4 => + V := Value (Image (First)) * 600 + + Value (Image (First + 1)) * 60 + + Value (Image (First + 2)) * 10 + + Value (Image (First + 3)); + + when 5 => + if Image (First + 2) in '0' .. '9' then + raise Constraint_Error with "Unknown time offset format"; + end if; + + V := Value (Image (First)) * 600 + + Value (Image (First + 1)) * 60 + + Value (Image (First + 3)) * 10 + + Value (Image (First + 4)); + + when others => + raise Constraint_Error with "Unknown time offset format"; + end case; + + if Negative then + return -V; + else + return V; + end if; + end Numeric; + end Parse_Time_Offset; + procedure Render_Triplet (Output : in out Ada.Streams.Root_Stream_Type'Class; Part_1, Part_2, Part_3 : in Atom; Template : in out Lockable.Descriptor'Class) is @@ -213,20 +304,40 @@ (Time_IO.RFC_3339.Image (Value.Source, Value.Time_Zone))); when Commands.Second => Format.Set_Image (-1, Null_Atom); Integers.Render (Output, Format, Arguments, Value.Second); + + when Commands.With_Offset => + if Arguments.Current_Event = Events.Add_Atom then + declare + use type Ada.Calendar.Time_Zones.Time_Offset; + New_Offset : Ada.Calendar.Time_Zones.Time_Offset; + begin + begin + New_Offset := Parse_Time_Offset + (S_Expressions.To_String (Arguments.Current_Atom), + Value.Source); + exception + when Constraint_Error => return; + end; + + Arguments.Next; + + if New_Offset = Value.Time_Zone then + Interpreter (Arguments, Output, Value); + else + Render (Output, Arguments, Value.Source, New_Offset); + end if; + end; + end if; when Commands.Year => Integers.Render (Output, Arguments, Value.Year); end case; end Execute; - - procedure Interpreter is new Interpreter_Loop - (Ada.Streams.Root_Stream_Type'Class, Split_Time, Execute, Append); - ---------------------- -- Public Interface -- ----------------------