Write Linux Free Pascal program that prints time shift between UTC time and local…
- User
Write Linux Free Pascal program that prints time shift between UTC time and local timezone. For example, for MSK timezone program should print "3".
- Assistant
You can create a Linux Free Pascal program to print the time shift between UTC time and the local timezone using the
DateTimefunctions available in theSysUtilsunit. The key idea is to get the current UTC time and the local time and then calculate the difference between them in hours. Here's a simple implementation:program TimeShift; uses SysUtils, DateUtils; var UTCNow, LocalNow: TDateTime; TimeShiftHours: Integer; begin // Get the current UTC time UTCNow := UTCNow; // Get the current local time LocalNow := Now; // Calculate the time difference in hours TimeShiftHours := HoursBetween(LocalNow, UTCNow); // Print the time shift WriteLn(TimeShiftHours); end.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.