Difference between revisions of "Truxton media get expires"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This retrieves the expiration date of the media. This corresponds to the <code>Expires</code> column of the <code>Media</code> table. This is the date that the media will be a...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This retrieves the expiration date of the media.
 
This retrieves the expiration date of the media.
This corresponds to the <code>Expires</code> column of the <code>Media</code> table.
+
This corresponds to the <code>[Expires]</code> column of the <code><nowiki>[</nowiki>[[Media Table|Media]]<nowiki>]</nowiki></code> table.
 
This is the date that the media will be automatically deleted from Truxton.
 
This is the date that the media will be automatically deleted from Truxton.
 
By default, it is 99 years from the creation date.
 
By default, it is 99 years from the creation date.
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint64_t truxton_media_get_expires( uint64_t media_handle );
 
uint64_t truxton_media_get_expires( uint64_t media_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 17: Line 17:
  
 
=Sample=
 
=Sample=
<syntaxhighlight lang="C" highlight="12">
+
<source lang="C" highlight="5">
void is_expired(uint64_t media)
+
void is_expired( uint64_t media )
 
{
 
{
   FILETIME now;
+
   uint64_t now = truxton_time_now();
  
  GetSystemTimeAsFileTime(&now);
+
   uint64_t expiration_date = truxton_media_get_expires( media );
 
 
  ULARGE_INTEGER ticks;
 
 
 
  ticks.LowPart = now.dwLowDateTime;
 
  ticks.HighPart = now.dwHighDateTime;
 
 
 
   uint64_t expiration_date = truxton_media_get_expires(media);
 
  
 
   if ( ticks.QuadPart() >= expiration_date )
 
   if ( ticks.QuadPart() >= expiration_date )
Line 39: Line 32:
 
       printf( "The media has not yet expired\n" );
 
       printf( "The media has not yet expired\n" );
 
   }
 
   }
}</syntaxhighlight>
+
}</source>

Latest revision as of 18:23, 13 April 2024

This retrieves the expiration date of the media. This corresponds to the [Expires] column of the [Media] table. This is the date that the media will be automatically deleted from Truxton. By default, it is 99 years from the creation date.

Syntax

uint64_t truxton_media_get_expires( uint64_t media_handle );

Parameters

media_handle

The handle created by the truxton_media_open_id or truxton_media_create call.

Return value

The expiration date of the media in FILETIME ticks.

Sample

void is_expired( uint64_t media )
{
   uint64_t now = truxton_time_now();

   uint64_t expiration_date = truxton_media_get_expires( media );

   if ( ticks.QuadPart() >= expiration_date )
   {
      printf( "The media has expired\n" );
   }
   else
   {
      printf( "The media has not yet expired\n" );
   }
}