Fixed timestamp to correctly use localtime(), thanks to mphipps. :-)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5633 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
933a883015
commit
003d4e83df
@ -44,6 +44,7 @@ const entity_id Udf::kMetadataPartitionMapId(0, "*UDF Metadata Partition");
|
|||||||
const entity_id Udf::kSparablePartitionMapId(0, "*UDF Sparable Partition");
|
const entity_id Udf::kSparablePartitionMapId(0, "*UDF Sparable Partition");
|
||||||
const entity_id Udf::kVirtualPartitionMapId(0, "*UDF Virtual Partition");
|
const entity_id Udf::kVirtualPartitionMapId(0, "*UDF Virtual Partition");
|
||||||
const entity_id Udf::kImplementationId(0, "*OpenBeOS UDF", implementation_id_suffix(OS_BEOS, BEOS_OPENBEOS));
|
const entity_id Udf::kImplementationId(0, "*OpenBeOS UDF", implementation_id_suffix(OS_BEOS, BEOS_OPENBEOS));
|
||||||
|
const entity_id Udf::kPartitionContentsId(0, "+NSR03");
|
||||||
|
|
||||||
//! crc 010041 table, as generated by crc_table.cpp
|
//! crc 010041 table, as generated by crc_table.cpp
|
||||||
const uint16 Udf::kCrcTable[256] = {
|
const uint16 Udf::kCrcTable[256] = {
|
||||||
@ -192,6 +193,7 @@ charspec::set_character_set_info(const char *info)
|
|||||||
// timestamp
|
// timestamp
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if !USER
|
||||||
static
|
static
|
||||||
int
|
int
|
||||||
get_month_length(int month, int year)
|
get_month_length(int month, int year)
|
||||||
@ -208,9 +210,29 @@ get_month_length(int month, int year)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
timestamp::timestamp(time_t time)
|
timestamp::timestamp(time_t time)
|
||||||
{
|
{
|
||||||
|
#if USER
|
||||||
|
// Is it me, or is localtime() broken?
|
||||||
|
tm *local = localtime(&time);
|
||||||
|
if (local) {
|
||||||
|
set_microsecond(0);
|
||||||
|
set_hundred_microsecond(0);
|
||||||
|
set_centisecond(0);
|
||||||
|
set_second(local->tm_sec);
|
||||||
|
set_minute(local->tm_min);
|
||||||
|
set_hour(local->tm_hour);
|
||||||
|
set_day(local->tm_mday);
|
||||||
|
set_month(local->tm_mon+1);
|
||||||
|
set_year(local->tm_year+1900);
|
||||||
|
set_type(1);
|
||||||
|
set_timezone(local->tm_gmtoff / 60);
|
||||||
|
} else {
|
||||||
|
_clear();
|
||||||
|
}
|
||||||
|
#else // no localtime() in the R5 kernel...
|
||||||
// real_time_clock() is returning the time offset by -16 hours.
|
// real_time_clock() is returning the time offset by -16 hours.
|
||||||
// Considering I'm -8 hours from GMT, this doesn't really make
|
// Considering I'm -8 hours from GMT, this doesn't really make
|
||||||
// sense. For the moment I'm offsetting it manually here, but
|
// sense. For the moment I'm offsetting it manually here, but
|
||||||
@ -250,26 +272,7 @@ timestamp::timestamp(time_t time)
|
|||||||
set_year(year+1970);
|
set_year(year+1970);
|
||||||
set_type(1);
|
set_type(1);
|
||||||
set_timezone(-2047); // -2047 == no timezone specified
|
set_timezone(-2047); // -2047 == no timezone specified
|
||||||
|
#endif
|
||||||
/*
|
|
||||||
// Is it me, or is localtime() broken?
|
|
||||||
tm *local = localtime(&time);
|
|
||||||
if (local) {
|
|
||||||
set_microsecond(0);
|
|
||||||
set_hundred_microsecond(0);
|
|
||||||
set_centisecond(0);
|
|
||||||
set_second(local->tm_sec);
|
|
||||||
set_minute(local->tm_min);
|
|
||||||
set_hour(local->tm_hour);
|
|
||||||
set_day(local->tm_mday);
|
|
||||||
set_month(local->tm_mon);
|
|
||||||
set_year(local->tm_year);
|
|
||||||
set_type(1);
|
|
||||||
set_timezone(local->tm_gmtoff);
|
|
||||||
} else {
|
|
||||||
_clear();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -128,10 +128,10 @@ public:
|
|||||||
t.bits.type = type;
|
t.bits.type = type;
|
||||||
set_type_and_timezone(t.type_and_timezone);
|
set_type_and_timezone(t.type_and_timezone);
|
||||||
}
|
}
|
||||||
void set_timezone(int16 timezone) {
|
void set_timezone(int16 tz) {
|
||||||
type_and_timezone_accessor t;
|
type_and_timezone_accessor t;
|
||||||
t.type_and_timezone = type_and_timezone();
|
t.type_and_timezone = type_and_timezone();
|
||||||
t.bits.timezone = timezone;
|
t.bits.timezone = tz;
|
||||||
set_type_and_timezone(t.type_and_timezone);
|
set_type_and_timezone(t.type_and_timezone);
|
||||||
}
|
}
|
||||||
void set_year(uint16 year) { _year = B_HOST_TO_LENDIAN_INT16(year); }
|
void set_year(uint16 year) { _year = B_HOST_TO_LENDIAN_INT16(year); }
|
||||||
@ -242,6 +242,7 @@ extern const entity_id kMetadataPartitionMapId;
|
|||||||
extern const entity_id kSparablePartitionMapId;
|
extern const entity_id kSparablePartitionMapId;
|
||||||
extern const entity_id kVirtualPartitionMapId;
|
extern const entity_id kVirtualPartitionMapId;
|
||||||
extern const entity_id kImplementationId;
|
extern const entity_id kImplementationId;
|
||||||
|
extern const entity_id kPartitionContentsId;
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// ECMA-167 Part 2
|
// ECMA-167 Part 2
|
||||||
@ -855,6 +856,9 @@ public:
|
|||||||
const array<uint8, 128>& implementation_use() const { return _implementation_use; }
|
const array<uint8, 128>& implementation_use() const { return _implementation_use; }
|
||||||
array<uint8, 128>& implementation_use() { return _implementation_use; }
|
array<uint8, 128>& implementation_use() { return _implementation_use; }
|
||||||
|
|
||||||
|
const array<uint8, 156>& reserved() const { return _reserved; }
|
||||||
|
array<uint8, 156>& reserved() { return _reserved; }
|
||||||
|
|
||||||
// Set functions
|
// Set functions
|
||||||
void set_vds_number(uint32 number) { _vds_number = B_HOST_TO_LENDIAN_INT32(number); }
|
void set_vds_number(uint32 number) { _vds_number = B_HOST_TO_LENDIAN_INT32(number); }
|
||||||
void set_partition_flags(uint16 flags) { _partition_flags = B_HOST_TO_LENDIAN_INT16(flags); }
|
void set_partition_flags(uint16 flags) { _partition_flags = B_HOST_TO_LENDIAN_INT16(flags); }
|
||||||
@ -864,7 +868,7 @@ public:
|
|||||||
f.bits.allocated = allocated;
|
f.bits.allocated = allocated;
|
||||||
set_partition_flags(f.partition_flags);
|
set_partition_flags(f.partition_flags);
|
||||||
}
|
}
|
||||||
|
void set_partition_number(uint16 number) { _partition_number = B_HOST_TO_LENDIAN_INT16(number); }
|
||||||
void set_access_type(uint32 type) { _access_type = B_HOST_TO_LENDIAN_INT32(type); }
|
void set_access_type(uint32 type) { _access_type = B_HOST_TO_LENDIAN_INT32(type); }
|
||||||
void set_start(uint32 start) { _start = B_HOST_TO_LENDIAN_INT32(start); }
|
void set_start(uint32 start) { _start = B_HOST_TO_LENDIAN_INT32(start); }
|
||||||
void set_length(uint32 length) { _length = B_HOST_TO_LENDIAN_INT32(length); }
|
void set_length(uint32 length) { _length = B_HOST_TO_LENDIAN_INT32(length); }
|
||||||
@ -893,16 +897,16 @@ private:
|
|||||||
uint32 _length;
|
uint32 _length;
|
||||||
entity_id _implementation_id;
|
entity_id _implementation_id;
|
||||||
array<uint8, 128> _implementation_use;
|
array<uint8, 128> _implementation_use;
|
||||||
uint8 _reserved[156];
|
array<uint8, 156> _reserved;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
|
||||||
enum partition_access_type {
|
enum partition_access_type {
|
||||||
PAT_UNSPECIFIED,
|
ACCESS_UNSPECIFIED,
|
||||||
PAT_READ_ONLY,
|
ACCESS_READ_ONLY,
|
||||||
PAT_WRITE_ONCE,
|
ACCESS_WRITE_ONCE,
|
||||||
PAT_REWRITABLE,
|
ACCESS_REWRITABLE,
|
||||||
PAT_OVERWRITABLE,
|
ACCESS_OVERWRITABLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user