mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rewrite gnc_gdate_set_time64 to not depend upon GDateTime.
This commit is contained in:
parent
19f64ad395
commit
6673128b9f
@ -131,17 +131,10 @@ commodity_ref_to_dom_tree(const char *tag, const gnc_commodity *c)
|
|||||||
* but we want to serialize it un-normalized, so we make a partial
|
* but we want to serialize it un-normalized, so we make a partial
|
||||||
* copy.
|
* copy.
|
||||||
*/
|
*/
|
||||||
gchar *
|
char *
|
||||||
timespec_sec_to_string(const Timespec *ts)
|
timespec_sec_to_string(const Timespec *ts)
|
||||||
{
|
{
|
||||||
gchar *time_string;
|
return gnc_print_time64(ts->tv_sec, "%Y-%m-%d %H:%M:%S %z");
|
||||||
GDateTime *gdt;
|
|
||||||
Timespec sts = { ts->tv_sec, 0};
|
|
||||||
gdt = gnc_g_date_time_new_from_timespec_local (sts);
|
|
||||||
g_return_val_if_fail (gdt != NULL, NULL);
|
|
||||||
time_string = g_date_time_format (gdt, "%Y-%m-%d %H:%M:%S %z");
|
|
||||||
g_date_time_unref (gdt);
|
|
||||||
return time_string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
|
@ -37,11 +37,10 @@ gnc_gdate_set_today (GDate* gd)
|
|||||||
void
|
void
|
||||||
gnc_gdate_set_time64 (GDate* gd, time64 time)
|
gnc_gdate_set_time64 (GDate* gd, time64 time)
|
||||||
{
|
{
|
||||||
GDateTime *gdt = gnc_g_date_time_new_from_unix_local (time);
|
struct tm tm;
|
||||||
gint y, m, d;
|
gnc_localtime_r(&time, &tm);
|
||||||
g_date_time_get_ymd (gdt, &y, &m, &d);
|
g_date_set_dmy (gd, tm.tm_mday, tm.tm_mon, tm.tm_year + 1900);
|
||||||
g_date_set_dmy (gd, d, m, y);
|
|
||||||
g_date_time_unref (gdt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -1653,10 +1653,6 @@ static gchar *generate_statusbar_lastmodified_message()
|
|||||||
int r = stat(filepath, &statbuf);
|
int r = stat(filepath, &statbuf);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
{
|
{
|
||||||
// File mtime could be accessed ok
|
|
||||||
gint64 mtime = statbuf.st_mtime;
|
|
||||||
GDateTime *gdt = gnc_g_date_time_new_from_unix_local (mtime);
|
|
||||||
gchar *dummy_strftime_has_ampm = g_date_time_format (gdt, "%P");
|
|
||||||
/* Translators: This is the date and time that is shown in
|
/* Translators: This is the date and time that is shown in
|
||||||
the status bar after opening a file: The date and time of
|
the status bar after opening a file: The date and time of
|
||||||
last modification. The string is the format string for
|
last modification. The string is the format string for
|
||||||
@ -1664,20 +1660,14 @@ static gchar *generate_statusbar_lastmodified_message()
|
|||||||
explanation of the modifiers. First string is for a locale
|
explanation of the modifiers. First string is for a locale
|
||||||
that has the a.m. or p.m. string in its locale, second
|
that has the a.m. or p.m. string in its locale, second
|
||||||
string is for locales that do not have that string. */
|
string is for locales that do not have that string. */
|
||||||
gchar *time_string =
|
char *time_string =
|
||||||
g_date_time_format (gdt, (dummy_strftime_has_ampm &&
|
gnc_print_time64(statbuf.st_mtime,
|
||||||
strlen(dummy_strftime_has_ampm) > 0)
|
_("Last modified on %a, %b %e, %Y at %I:%M%P"));
|
||||||
? _("Last modified on %a, %b %e, %Y at %I:%M%P")
|
|
||||||
: _("Last modified on %x %X"));
|
|
||||||
|
|
||||||
g_date_time_unref (gdt);
|
|
||||||
|
|
||||||
//g_warning("got time %ld, str=%s\n", mtime, time_string);
|
//g_warning("got time %ld, str=%s\n", mtime, time_string);
|
||||||
/* Translators: This message appears in the status bar after opening the file. */
|
/* Translators: This message appears in the status bar after opening the file. */
|
||||||
message = g_strdup_printf(_("File %s opened. %s"),
|
message = g_strdup_printf(_("File %s opened. %s"),
|
||||||
filename, time_string);
|
filename, time_string);
|
||||||
g_free(time_string);
|
free(time_string);
|
||||||
g_free(dummy_strftime_has_ampm);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user