date
                                                                                
 Documentation                                                                  
                          Extract a date object from a string.                  
                                                                                
                          This module is not really smart yet, currently it     
                          uses the following regex to extract a date (which     
                          might fail in a lot of cases):                        
                                                                                
                          ┌─────────────────────────────────────────────────┐   
                          │ r"_(\d{4}-\d{2}-\d{2})_"                        │   
                          └─────────────────────────────────────────────────┘   
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         core                                     
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field       Type     Description           Required   
                         ─────────────────────────────────────────────────────  
                          constants   object   Value constants for   no         
                                               this module.                     
                          defaults    object   Value defaults for    no         
                                               this module.                     
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    ExtractDateModule                       
                          module_name   kiara_modules.core.date                 
                          full_name     kiara_modules.core.date.ExtractDateM…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              from dateutil import parser                       
                                                                                
                              text = inputs.get_value_data("text")              
                              date_match = re.findall(r"_(\d{4}-\d{2}-\d{2})…   
                              assert date_match                                 
                              d_obj = parser.parse(date_match[0])  # type: i…   
                                                                                
                              outputs.set_value("date", d_obj)                  
                                                                                
                         ─────────────────────────────────────────────────────  
                                                                                
date.range_check
                                                                                
 Documentation                                                                  
                          Check whether a date falls within a specified date    
                          range.                                                
                                                                                
                          If none one of the inputs 'earliest' or 'latest' is   
                          set, this module will always return 'True'.           
                                                                                
                          Return True if that's the case, otherwise False.      
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         core                                     
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field       Type     Description           Required   
                         ─────────────────────────────────────────────────────  
                          constants   object   Value constants for   no         
                                               this module.                     
                          defaults    object   Value defaults for    no         
                                               this module.                     
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    DateRangeCheckModule                    
                          module_name   kiara_modules.core.date                 
                          full_name     kiara_modules.core.date.DateRangeChe…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              from dateutil import parser                       
                                                                                
                              d = inputs.get_value_data("date")                 
                              earliest: typing.Optional[datetime.datetime] =…   
                              latest: typing.Optional[datetime.datetime] = i…   
                                                                                
                              if not earliest and not latest:                   
                                  outputs.set_value("within_range", True)       
                                  return                                        
                                                                                
                              if hasattr(d, "as_py"):                           
                                  d = d.as_py()                                 
                                                                                
                              if isinstance(d, str):                            
                                  d = parser.parse(d)                           
                                                                                
                              if earliest and latest:                           
                                  matches = earliest <= d <= latest             
                              elif earliest:                                    
                                  matches = earliest <= d                       
                              else:                                             
                                  matches = d <= latest                         
                                                                                
                              outputs.set_value("within_range", matches)        
                                                                                
                         ─────────────────────────────────────────────────────