Add iso8601_cmp(), comparison function for qsort()
This commit is contained in:
		
							parent
							
								
									d09e55e8ae
								
							
						
					
					
						commit
						1d9447dcd2
					
				| 
						 | 
					@ -38,6 +38,19 @@ int iso8601_eq(const struct iso8601_date* d1, const struct iso8601_date* d2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int iso8601_cmp(const struct iso8601_date* d1, const struct iso8601_date* d2)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if(d1->day < d2->day) return -1;
 | 
				
			||||||
 | 
					    if(d1->day > d2->day) return 1;
 | 
				
			||||||
 | 
					    if(d1->sec < d2->sec) return -1;
 | 
				
			||||||
 | 
					    if(d1->sec > d2->sec) return 1;
 | 
				
			||||||
 | 
					    if(d1->nsec < d2->nsec) return -1;
 | 
				
			||||||
 | 
					    if(d1->nsec > d2->nsec) return 1;
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void iso8601_add_elapsed(struct iso8601_date* date, const struct iso8601_elapsed* per)
 | 
					void iso8601_add_elapsed(struct iso8601_date* date, const struct iso8601_elapsed* per)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    div_t qr;
 | 
					    div_t qr;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,6 +53,19 @@ int iso8601_eq(const struct iso8601_date* d1, const struct iso8601_date* d2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*! \brief Comparison (for qsort et al.).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					\param d1 First date to compare.
 | 
				
			||||||
 | 
					\param d2 Second date to compare.
 | 
				
			||||||
 | 
					\retval -1 if \a d1 < \a d2
 | 
				
			||||||
 | 
					\retval 0 if \a d1 == \a d2
 | 
				
			||||||
 | 
					\retval 1 if \a d1 > \a d2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					int iso8601_cmp(const struct iso8601_date* d1, const struct iso8601_date* d2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*! \brief Add a period to a date.
 | 
					/*! \brief Add a period to a date.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\param[in,out] date Date to modify.
 | 
					\param[in,out] date Date to modify.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue